-
Notifications
You must be signed in to change notification settings - Fork 79
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
Thumbnail image size improvements #1224
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this change, it is necessary to run ./vendor/bin/sake dev/tasks/MigrateFileTask generate-cms-thumbnails
Yeah that's a bit of a deal breaker right now, as is seems like we'll break all the sites :-) We're not going to do that just to make thumbnails a little sharper
HiDPI
What type of device are you using so that you noticed the blurry thumbnails? Are you running the CMS on an ipad?
@purplespider I've created a parent issue for this here and which also links another issue for retina image support |
Yeah ... I agree with Steve that requiring everyone to run a migration task is a bit overkill given the severity of this issue. I guess we could ship an updated config in the installer, so people starting new project get the better settings when starting a new project |
d6910d8
to
689f4aa
Compare
I've rebased and retargetted to The same problem with needing to update all thumbnails (currently by saving the files, or by running a migration task as discussed above) also plagues the scenario where developers choose to change this same configuration in their project, so definitely is a bug we should look to fix if feasible. Edit: Looks like the graphql request for files was explicitly not generating missing thumbnails... which seems supremely silly so I've switch that. We only load a limited number of items per page and in most scenarios those will already have their thumbnails generated ahead of time (on initial image save). I don't think there's any risk of a noticable performance degradation by making this change, and it lets us have these nice non-blurry thumbnails. |
And updated unit tests to match the new file names. |
It's not just the UI that can run the gql requests, right? It would be limited to logged-in users, but could still be a DDoS/performance degradation vector if queried without the limits? |
I'd be probably ok with this in a minor and mention in a changelog. |
b47dcbe
to
0d15880
Compare
Let me take a look into that - that's a good point. |
To ensure thumbnails are still crisp on 2x displays.
To avoid images being unnecessarily upscaled in CSS, resulting in blurry thumbs.
0d15880
to
c398cdd
Compare
I've added a new commit which aims to limit the scope of which files we're allowed to generate thumbnails for - each GraphQL query should now only be allowed to generate thumbnails for up to 100 files, which is 2x the current asset admin page limit. I've also retargetted and rebased for the |
Looks ok to me but I'd prefer if there was another pair of eyes over this. |
c398cdd
to
ce989a7
Compare
Sweet. I've updated to use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just small question.
$idsAllowed = FolderTypeResolver::getIdsAllowedToGenerateThumbnails(); | ||
$shouldGenerateThumbnail = !empty($idsAllowed) && in_array($object->ID, $idsAllowed); | ||
if ($shouldGenerateThumbnail) { | ||
$origGenerates = $generator->getGenerates(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tiny question, should we have $origGenerates
declaration in if
block? This question just in case, if in the future we will have additional logic in this method.
Upload field: Image gallery (List view): I'm not entirely sure that this is important or that anyone will notice it, but there is a slight difference between how the preview is displayed when viewing in list mode in the "Files" section. I personally like PR version a lot, but what about the user’s expectations. |
Good spotting! That is important. I hadn't noticed it in my testing but yeah we don't want to give false representations of what images look like. I'll take a gander at what we can do about that. |
That's made me realise this change would affect anyone who's using I think what we really need is a way to declare different thumbnails depending on the context - so we would use This PR isn't doing that, and I think that would be a lot of work. @purplespider if you'd like to persue this further lets continue discussion in the issue, get a way forward we're all happy with, and then open a new PR from there. |
Issue: #1228
This PR corrects thumbnail image sizes to ensure they are crisp and not blurry.
Thumbnails are typically displayed at a consistent size, yet,
ThumbnailGenerator
currently uses theFitMax
resize method, which results in differently sized images. These are then currently resized and cropped in CSS (usingbackground-size: cover
) to make them display at a consistent size. However, due toFitMax
this results in nearly all thumbnails being upscaled and thus displaying blurrier than they should. Very wide or tall images are most affected by this, especially inUploadField
thumbnails.This PR changes the default
ThumbnailGenerator
resize method fromFitMax
toFill
so that the resulting image is exactly the desired size, and no upscaling in CSS is necessary.NOTE: After this change, it is necessary to run./vendor/bin/sake dev/tasks/MigrateFileTask generate-cms-thumbnails
to re-create the CMS thumbnails, otherwise NO thumbnails will display in the "Files" area. Open to suggestions for making this an optional change for existing sites.The default thumbnail dimensions for
UploadField
are also doubled from60
to120
to ensureUploadField
thumbnails remain crisp on HiDPI displays.