Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add figure badges to entry thumbs and for gif image #556

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

asdfzdfj
Copy link
Contributor

@asdfzdfj asdfzdfj commented Mar 6, 2024

add GIF badge to attached image preview when image src ends with .gif to notify viewer and maybe hopefully invite them to check out the full image

image

image

added because the thumbnail filter with standard gd can't handle animated gifs at the moment (and doesn't look like it ever will), so it will appear static although it could be an animated image

the detection is based on filename extension, so for local image it should be fairly accurate since filename is normalized with extension generated based on its type, but possibly hit and miss for remote image though

@melroy89
Copy link
Member

melroy89 commented Mar 6, 2024

As you noticed earlier in the matrix chat some images do not always end with .gif despite being it a GIF image. I think it's fine for now, but you could also check the image type AKA MIME type.

Copy link
Member

@melroy89 melroy89 left a comment

Choose a reason for hiding this comment

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

Approved for now, but see my comment.

add `GIF` badge to attached image preview and entry thumbnail when image
src ends with `.gif` to notify viewer and maybe hopefully invite them to
checkout the full image

added because the thumbnail filter with standatd gd can't handle
animated gifs at the moment, so it will appear static although it could
be an animated image

due to space constraints, the badges for entry thumbnail in compact
mobile layout will be hidden entirely

the detection is based on filename extension, so for local image it
should be fairly accurate since filename is normalized with extension
generated based on its type, but possibly hit and miss for remote image
though
@asdfzdfj asdfzdfj merged commit 4455e5c into main Mar 6, 2024
7 checks passed
@asdfzdfj asdfzdfj deleted the new/figure-thumb-gif-badge branch March 6, 2024 16:54
@asdfzdfj
Copy link
Contributor Author

asdfzdfj commented Mar 6, 2024

As you noticed earlier in the matrix chat some images do not always end with .gif despite being it a GIF image. I think it's fine for now, but you could also check the image type AKA MIME type.

I'm well aware of that, but that should only be a problem for remote images that's produced by #501 (i.e. having the Image entity but not having a filePath with already normalized extension from its mime type set), if you want accurate detection of these images then it'll likely need something to load the remote image to check its type everytime, either server side check while templating or a client-side js that adds the badge after the fact (as we don't directly store image mime types), both of which I'm not too keen to add it just for this.

also the badges are only added for image figures that's being templated server side using the Image entity, the ones from embed preview links is another story and isn't covered by this (besides, if it's animated gif then you'll see it, there's no animation-less thumbnailer in the way).

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.

None yet

2 participants