Skip to content

Use default thumbnails as a fallback while real ones are loading - #3934

Open
thatbudakguy wants to merge 1 commit into
mainfrom
thumbnail-fallback
Open

thatbudakguy wants to merge 1 commit into
mainfrom
thumbnail-fallback

Conversation

@thatbudakguy

Copy link
Copy Markdown
Member

You can set default_thumbnail to a single value or a proc or method,
which currently allows GeoBlacklight to render an icon thumbnail
for every record based on its content type. This is pretty useful.

This PR takes advantage of that in the case where we have both
a default_thumbnail and the record has a thumbnail image of its own.
In this case loading the thumbnail from an external location can
sometimes be quite slow (if it's not cached yet) or even fail.

This change just renders the default thumbnail with the record's
real one stacked on top of it, so that the default gets used as
a fallback while the loading happens, and stays there if the
loading fails. The items are stacked using CSS, so there's no
javascript needed to make it work.

@thatbudakguy

Copy link
Copy Markdown
Member Author

I upstreamed this from geoblacklight/geoblacklight#1970, since it didn't feel specific to GeoBlacklight.

@thatbudakguy
thatbudakguy changed the base branch from main to rubocop-fix October 16, 2026 20:04
@thatbudakguy
thatbudakguy added this pull request to stack #3936 October 16, 2026 20:05
@thatbudakguy
thatbudakguy marked this pull request as ready for review October 16, 2026 20:05
Base automatically changed from rubocop-fix to main October 16, 2026 20:30
@jcoyne
jcoyne force-pushed the thumbnail-fallback branch from 673c5a9 to 147c133 Compare October 16, 2026 20:30
grid-area: 1 / 1;
}

.thumbnail-fallback {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we're placing both images in one cell and only centering the fallback? If the default image is larger than the record image, parts of the default remain visible around the loaded image, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can't happen because we're always forcing the thumbnail to width: 100%; height: 100%, so if it renders at all, it will completely cover the fallback.

The behavior prior to this PR does allow thumbnails to not fully cover the container:

Screenshot 2026-10-28 at 11 03 29

But after, they always cover:

Screenshot 2026-10-28 at 11 03 18

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...realized this was from the earlier branch in GBL, and I forgot to port that part. great catch.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated so that the real thumbnail is always at least as large as the fallback.

@thatbudakguy
thatbudakguy force-pushed the thumbnail-fallback branch 4 times, most recently from c6b00f3 to 605eea3 Compare October 28, 2026 18:59
You can set default_thumbnail to a single value or a proc or method,
which currently allows GeoBlacklight to render an icon thumbnail
for every record based on its content type. This is pretty useful.

This PR takes advantage of that in the case where we have both
a default_thumbnail and the record has a thumbnail image of its own.
In this case loading the thumbnail from an external location can
sometimes be quite slow (if it's not cached yet) or even fail.

This change just renders the default thumbnail with the record's
real one stacked on top of it, so that the default gets used as
a fallback while the loading happens, and stays there if the
loading fails. The items are stacked using CSS, so there's no
javascript needed to make it work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants