windows-azure-storage icon indicating copy to clipboard operation
windows-azure-storage copied to clipboard

Srcset returning local media url instead of azure url

Open nreddipalle opened this issue 5 years ago • 3 comments

Tested on WordPress Version: 5.5.3 Plugin Version: 4.3.1

Used this Plugin https://wordpress.org/plugins/velvet-blues-update-urls/ to update my urls.. On viewing page source, I still find SrcSet returning local media URL even when Src is showing correctly Azure Blob url fine..

<p><img class="alignnone wp-image-1815" src="https://senseimarketingstaging.blob.core.windows.net/uploads/2018/08/Team_Eggplant_Blues.png" alt="Team of three people" width="116" height="75" srcset="https://stage.senseilabs.com/wp-content/uploads/2018/08/Team_Eggplant_Blues.png 556w, https://stage.senseilabs.com/wp-content/uploads/2018/08/Team_Eggplant_Blues-300x194.png 300w" sizes="(max-width: 116px) 100vw, 116px" /></p>

How to fix this??

nreddipalle avatar Nov 10 '20 00:11 nreddipalle

@jeffpaul ??

nreddipalle avatar Nov 11 '20 06:11 nreddipalle

@nreddipalle apologies, I don't have an immediate answer for you. We'll try and take a look into this, but in the meantime have you validated functionality with the Velvet Blues team?

jeffpaul avatar Nov 12 '20 03:11 jeffpaul

I had a similar issue. Our situation is that we are migrating existing uploads to Azure storage manually. I'm not sure if this is the same situation as the OP. (This is with plugin version 4.3.3 and WP vsn 6.0.2.)

The issue is in the windows_azure_storage_wp_calculate_image_srcset function, it is trying to pull the azure metadata (windows_azure_storage_info) for the post but there isn't any since the uploads were manually added. I modified the function to replicate the part of windows_azure_storage_wp_generate_attachment_metadata that adds the metadata to the table (without the parts that push files up). So when loading the page, if it doesn't detect the metadata, it adds back in at that point.

I'm willing to do a PR if you want, but I'm not sure that is the best way to handle this in the long run. At the very least we could refactor that metadata update into a new function that could be called from either of the two existing ones.

bpalme avatar Oct 07 '22 15:10 bpalme