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

Bump priority in hook to make webp conversion works #231

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

hugosolar
Copy link
Contributor

@hugosolar hugosolar commented Jun 14, 2024

Description of the Change

this change closes #191
I was able to investigate this issue and enabling performance lab and enable webp option causes the plugin just uploads webp converted images from intermediate images excluding the original.

Because of this plugin uses wp_generate_attachment_metadata hook to upload images to blob container, there seems to be a priority conflict with WordPress native conversion from the original image at the moment of uploading to the container.
Increasing the hook priority to 10, make the plugin work as expected and upload the webp converted original image and also the original image itself which is the expected behavior (as referred by the official documentation).
After uploading to the blob container and checked the meta data I'm able to see the original jpeg image is kept into the meta field

'sources' => 
  array (
    'image/webp' => 
    array (
      'file' => 'kitty_meow-jpg.webp',
      'filesize' => 54832,
    ),
  ),
  'original_image' => 'kitty_meow.jpg',
  'url' => 'https://azurethumbs.blob.core.windows.net/playground/2024/06/kitty_meow-jpg.webp',

Also, the windows_azure_storage_info attachment meta field is keeping both images

array (
  'container' => 'playground',
  'blob' => '2024/06/kitty_meow-jpg.webp',
  'url' => 'https://azurethumbs.blob.core.windows.net/playground/2024/06/kitty_meow-jpg.webp',
  'thumbnails' => 
  array (
    0 => '2024/06/kitty_meow-300x200.webp',
    1 => '2024/06/kitty_meow-150x150.webp',
    2 => '2024/06/kitty_meow-768x512.webp',
    3 => '2024/06/kitty_meow.jpg',
  ),
  'version' => '4.4.2',
)

Screenshot 2024-06-14 at 14 58 13

How to test the Change

  • Enable Azure storage plugin
  • Enable performance lab plugin
  • Enable webp in the plugin settings
  • Upload image
  • Using Azure storage explorer checks the directory and original image and its web converted version should have been uploaded
  • Check the following meta fields. both should make reference to the original image and its webp version
    • _wp_attachment_metadata
    • windows_azure_storage_info
  • _wp_attached_file should point to the webp original version

Changelog Entry

Fixed - Bug fix
Fixed webp compatibility when uploading original images as described in #191

Credits

@hugosolar, @ali-awwad (for reporting it)

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@hugosolar hugosolar self-assigned this Jun 14, 2024
@rickalee
Copy link
Collaborator

@hugosolar Simple yet effective update. Approved. cc @jeffpaul

@jeffpaul jeffpaul added this to the 4.5.0 milestone Jun 17, 2024
@jeffpaul jeffpaul merged commit e07dd06 into 10up:develop Jun 17, 2024
2 of 5 checks passed
@jeffpaul
Copy link
Member

@hugosolar I'm noting now that this PR had e2e failures as does #230, so hoping you can look into that either in a new PR or perhaps updated on #230?

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.

Webp copy of original jpeg image not uploading to Azure Storage
3 participants