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

Add image replacement feature #230

Open hugosolar opened 1 month ago

hugosolar commented 1 month ago

Description of the Change

Extending our previous feature to replace PDFs in #220 Now I'm adding the feature to replace images. The criteria to replace images is based on the source image, we're using it as a reference to handle metadata The process is to loop over the registered sizes for the image and find the image with the nearest size from the replacement and replace the correspondent image size. This approach seems to be the one used by known plugins like Enable Media replace

The workflow we're following is

https://drive.google.com/file/d/1vPuk_cYUdWrlGBY3bUkjxWTpZeYr-BTG/view

This plugin also fixes #184 ensuring we're processing an array with array_flip otherwise returning a WP_Error object closes #182 #130

How to test the Change

Changelog Entry

Added - New feature Feature to replace images at the blob storage level

Fixed - Bug fix Fixed bug relate to the use of array_flip and not ensuring it was an actual arrat

Credits

Props @hugosolar

Checklist:

jeffpaul commented 1 month ago

@rickalee looking to you / your team for review / approval here

rickalee commented 2 weeks ago

@hugosolar Approved. Looks great. Any considerations with Cache and configuration we need to document for other users of public plugin?

hugosolar commented 2 weeks ago

@rickalee I've addressed cache issue by setting the blob properties cache to 30 segs Screenshot 2024-06-17 at 14 42 01

hugosolar commented 2 weeks ago

@jeffpaul the e2e error seems to come directly from wp-env

ERROR: for f505fb82f2963a5299b2972f47ad8834_mysql_1  'ContainerConfig'
Creating f505fb82f2963a5299b2972f47ad8834_tests-wordpress_1 ... done
Creating f505fb82f2963a5299b2972f47ad8834_tests-cli_1       ... 
Creating f505fb82f2963a5299b2972f47ad8834_tests-cli_1       ... done
[2378] Failed to execute script docker-compose

ERROR: for mysql  'ContainerConfig'

have you seen this before? actually, we're using @wordpress/env 8.7.0 in the plugin and it's currently at 2.0.0 I can try to update that library and see how it goes

dkotter commented 2 weeks ago

@hugosolar Yes, updating @wordpress/env to the latest should fix that particular issue, as we've ran across this on a few other plugins. Seems GitHub updated the ubuntu-latest image and this causes issues with wp-env if it's not running the latest

hugosolar commented 2 weeks ago

@dkotter @jeffpaul I've updated wp-env and I can see the build is passing now now it's failing on cypress tests since I'm pushing from a forked repository and secrets aren't available to accomplish those tests. This has been fixed on my other PRs let me know how can I help with this

jeffpaul commented 1 week ago

Note I'm holding for @rickalee's review before merging here