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

Refine logic to select smaller image size #292

Closed
felixarntz opened this issue Apr 12, 2022 · 1 comment · Fixed by #302
Closed

Refine logic to select smaller image size #292

felixarntz opened this issue Apr 12, 2022 · 1 comment · Fixed by #302
Assignees
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Milestone

Comments

@felixarntz
Copy link
Member

As outlined in #186 (comment), there is a flaw with the current approach of choosing the smaller image MIME file in frontend content:

  • The current implementation only looks at the full image and decides based on that which MIME type should be preferred.
  • But what if e.g. for most image sizes (including full) the WebP image is smaller, but for e.g. thumbnail the JPEG image is smaller? The current implementation would still always use WebP in that scenario, but it would be better to use JPEG for the thumbnail size.
  • So I'm thinking maybe we need to enhance this to more deeply integrate into the replacement logic, per image size, rather than the overall MIME types filter.

While attaching the webp_uploads_get_mime_types_by_filesize() function to the webp_uploads_content_image_mimes filter seems elegant, I think this is the wrong integration point here. It's not sufficient to universally choose a preferred MIME type based on the full image size. We have to instead modify webp_uploads_img_tag_update_mime_type() directly and make this check for every image size individually.

@felixarntz felixarntz added [Type] Enhancement A suggestion for improvement of an existing feature [Focus] Images Needs Dev Anything that requires development (e.g. a pull request) [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels Apr 12, 2022
@felixarntz
Copy link
Member Author

cc @jjgrainger @mitogh

@jjgrainger jjgrainger self-assigned this Apr 14, 2022
@mitogh mitogh added Needs Review and removed Needs Dev Anything that requires development (e.g. a pull request) labels Apr 18, 2022
@felixarntz felixarntz added this to the 1.1.0 milestone May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
None yet
3 participants