-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Synced Pattern Overrides: Image metadata like data-permalink, data-image-title, keeps original image data #62886
Comments
Are there any plugins active other than Gutenberg? In my testing, I do not see any of these data attributes in a local install. However, I so see them when Jetpack is enabled and the Media settings are enabled. cc @jeherve |
Yes, you are correct, I apologize. Jetpack is enabled. This particular client site is hosted on wp.com, not something I usually work with, and they silently force certain plugins on you. I forgot to make sure it was disabled. |
No worries, this likely has implications for any third-party plugin that modifies block content before it's rendered. |
Yes, I agree. It is not a bug in Gutenberg then, apologies. Thanks for looking into it, though! |
Not sure if you created an issue already @perezcarreno, but the jetpack repo is here - https://github.com/Automattic/jetpack/issues. I'd be curious to know if the issue only happens with the gutenberg plugin active, or if it still happens in the WP6.6 beta. There's a few small differences with the way the gutenberg plugin handles block bindings (the feature that pattern overrides is built on) compared to WordPress core. Gutenberg only overrides the block attributes like the image id later in the block rendering process, so it might be that jetpack doesn't have access to the correct image id. |
I created an issue to keep track of this here:
The root issue is present with both as far as I can tell, but is only visible to visitors when Gutenberg is active. When Gutenberg is inactive, you cannot link an image inside a synced pattern to its attachment page: As a result, Jetpack's Carousel will not be triggered.
That seems to be the root of the problem here. In the post content, the block with a replaced image would be saved like so: <!-- wp:block {"ref":40,"content":{"original":{"id":44,"alt":"","url":"https:/mysite.com/wp-content/uploads/2024/06/replaced-1024x383.png"}}} /--> Where However, some third-party plugins like Jetpack only parse the post content using a filter like <figure class="wp-block-image size-large"><img src="https://my-site.com/wp-content/uploads/2024/06/replaced-1024x383.png" alt="" class="wp-image-39"/></figure>
Would there be a way to fix this in Core? |
I'll reopen the issue as it seems worth discussing further, and I don't want it to get lost. It's also something that could happen with any block binding, including if the user is binding an image block using post meta, so I'm re-labelling the issue.
That will land in the next release of the plugin as well, though I don't think that the image needs a link to be able to reproduce the issue.
Does jetpack use the |
Thanks for taking another look!
Yes, that's how its Carousel feature currently works for single images.
It seems like it would make sense. I think it's a fair expectation to have the class name matching the image displayed on the page. |
Thank you, @jeherve ! I haven't tested it on 6.6, but with Gutenberg the way that I added the link to the image was after creating the override. In other words, the "Overrides currently don't support image captions or links" legend is not shown to the user because the link isn't there yet. Then, once the override is set, I went in and added the link. I don't know if this helps, but I thought I'd mention it. |
Similar to the issue with the I'll try to fix that at the same time, as I see from the PR it's used by some themes. |
I've made a PR that should hopefully fix this - #63013 |
Description
When you create a synced pattern and include an image override, the original image's metadata will be shown in the HTML even when you've chosen a new image in a pattern's instance. So if the image was called 'my-image-placeholder.jpg", that is the data that will be shown in the code, even if the displayed image is "bird-graphic.jpg".
For example:
<img decoding="async" data-attachment-id="28" data-permalink="https:/website.com/placeholder-image-11/" data-orig-file="https://website.com/wp-content/uploads/2024/03/woocommerce-placeholder.png" data-orig-size="800,800" data-comments-opened="1" data-image-meta="{"aperture":"0","credit":"","camera":"","caption":"","created_timestamp":"0","copyright":"","focal_length":"0","iso":"0","shutter_speed":"0","title":"","orientation":"0"}" data-image-title="Placeholder Image" data-image-description="" data-image-caption="" data-medium-file="https://website.com/wp-content/uploads/2024/03/woocommerce-placeholder.png" data-large-file="https://website.com/wp-content/uploads/2024/03/woocommerce-placeholder.png" src="https://website.com/wp-content/uploads/2024/06/V3P100-129fig5.jpg" alt="Figure 5. A histogram plot showing distribution of missing death data according to age group" class="wp-image-28" style="object-fit:cover">
P.S. I might open another issue if I have time, but so I don't forget, the same thing happens if you had enabled a link in the image after creating the override. The best example being the "attachment" link which opens the image in a lightbox. It also shows the placeholder image in the lightbox instead of the current instance's image.
Thanks!
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Environment info
WordPress 6.5.5, Gutenberg 18.6.0
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: