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

Meta flood for zero-sizes #24

Open
1 task done
vralle opened this issue Feb 3, 2022 · 3 comments
Open
1 task done

Meta flood for zero-sizes #24

vralle opened this issue Feb 3, 2022 · 3 comments
Labels
help wanted Extra attention is needed needs:engineering This requires engineering to resolve. type:bug Something isn't working.

Comments

@vralle
Copy link

vralle commented Feb 3, 2022

Describe the bug

The easiest way to remove thumbnail generation of a image size is to set the width and height to 0.
This is an example of wp_get_additional_image_sizes() values:

array (
  '1536x1536' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
  '2048x2048' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
  'medium_large' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
  'woocommerce_gallery_thumbnail' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
  'shop_catalog' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
  'shop_single' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
  'shop_thumbnail' => 
  array (
    'width' => 0,
    'height' => 0,
    'crop' => 0,
  ),
);

WordPress skips generation of such thumbnails. The plugin generates thumbnail metadata, where width and height can be 0.

This behavior results in unexpected behavior when using thumbnails. For example, structured data generation plugins can use zero-sizes for thumbnails.

This behavior is related #23

Steps to Reproduce

  1. Disable image size by simply step:
	add_image_size( 'medium_large', 0, 0, 0 );
  1. Upload the SVG image
  2. See generated metadata for attachment

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@vralle vralle added the type:bug Something isn't working. label Feb 3, 2022
@vralle vralle changed the title Meta food for zero-sizes Meta flood for zero-sizes Feb 3, 2022
@vikrampm1 vikrampm1 moved this to Incoming in Open Source Practice Feb 3, 2022
@jeffpaul jeffpaul moved this from Incoming to Backlog in Open Source Practice Feb 3, 2022
@jeffpaul jeffpaul added needs:engineering This requires engineering to resolve. help wanted Extra attention is needed labels Feb 3, 2022
@jeffpaul jeffpaul added this to the Future Release milestone Feb 3, 2022
@jeffpaul
Copy link
Member

@darylldoyle any thoughts on best approach here for an engineer to help with?

@vralle
Copy link
Author

vralle commented Jun 28, 2022

Here's what I remember.
I could not find the need to generate metadata for the SVG. It is always a link to one file. We can generate an image tag of any size. Only the width and height attributes change. Sizes is available through filters.
I may be wrong, but I've come to the conclusion that there is no need for persistent image size metadata. Instead, we can use a metadata filter that can return any size on request.
The downside of this approach is that we won't be able to set dimensions for removed dimensions. This scenario is possible in case of using outdated sizes in templates/rest-client. Probably, in this case, you can generate a default size with the hope that this will not lead to a violation of the layout.

@vralle
Copy link
Author

vralle commented Jun 29, 2022

Here is what I did:
https://gist.github.com/vralle/f45d68d758e2d26e54b99b71fa13f5e4

  1. SVG sizes in metadata is no longer needed
  2. Image tags are not using safe_svg->svg_dimensions
  3. Image sizes are generated upon request. Image aspect ratio is preserved (responsive sizes require additional code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed needs:engineering This requires engineering to resolve. type:bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants