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

Image PreviewLink should not be used by asset-admin, because it ignores resample_images config setting #1374

Open
p0lar-bear opened this issue Apr 19, 2023 · 3 comments

Comments

@p0lar-bear
Copy link

p0lar-bear commented Apr 19, 2023

Image::PreviewLink() always calls ImageManipulation::FitMax(), which in turn will always create a copy of an image if one doesn't exist, regardless of whether or not the image is large enough to be rescaled. I'm not exactly sure where in this chain of events it should happen, but I feel like there should be a check against the File::resample_images config setting to prevent this from happening and to just use the full-size image's URL if resample_images is set to false. At least, I can work around this for now by subclassing Image and editing the config for File::class_for_file_extension to override the default class definitions for the image extensions.

In my use-case, I'm not using SilverStripe as a traditional CMS - I do not need images to be optimized for quick delivery and consumption, and do not want the assets directory to be littered with thumbnails alongside the source images.

@GuySartorelli
Copy link
Member

I'm not sure whether to label this a bug or an enhancement.... does this actually cause some failure of functionality at all or is the only downside that you have more files on the filesystem?

@p0lar-bear
Copy link
Author

Sorry for the late response on this.

I personally feel this should probably be labeled as a bug. While there isn't a "failure" in the sense of something being rendered unusable, the fact remains that there is a switch here, and the functionality that it purportedly controls still happens regardless of whether it's switched "off". That is, by definition, a bug.

I'm aware I have a strange use-case and I don't kid myself for a moment thinking that there's any urgency or high priority to it, but when something doesn't do the thing it's described to do, it should be brought to attention.

@GuySartorelli
Copy link
Member

Thank you for that additional information.

I'm just looking at the code now. The PHPDoc comment for the resample_images configuration property says:

Control whether images in the admin will be resampled

In other words this configuration must not affect the front-end. Really it should be declared somewhere in silverstripe/asset-admin... but in any case, the PreviewLink() method can be used on the front-end to get a thumbnail for display, so the problem isn't so much that PreviewLink() ignores the config setting, but that it is used by asset-admin regardless of the setting.

I'm going to rename the issue to reflect that and move it to the asset-admin repository.

@GuySartorelli GuySartorelli changed the title Image PreviewLink ignores resample_images config setting and generates a thumbnail anyway Image PreviewLink should not be used by asset-admin, because it ignores resample_images config setting Jul 19, 2023
@GuySartorelli GuySartorelli transferred this issue from silverstripe/silverstripe-assets Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants