10up / windows-azure-storage

Use the Microsoft Azure Storage service to host your website's media files.
https://wordpress.org/plugins/windows-azure-storage/
BSD 2-Clause "Simplified" License
58 stars 46 forks source link

Bump priority in hook to make webp conversion works #231

Closed hugosolar closed 2 weeks ago

hugosolar commented 3 weeks ago

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

Changelog Entry

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

Credits

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

Checklist:

rickalee commented 3 weeks ago

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

jeffpaul commented 2 weeks ago

@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?