-
Notifications
You must be signed in to change notification settings - Fork 2k
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
“Automatically use the first image in post as the Featured Image” setting doesn't work for Atomic sites #86093
Comments
@TimBroddin is this something Apex could look into, as you folks developed the feature originally? Might just need adding the option to the list of options to sync in Jetpack? |
Did this not work:
Or did the toggle not work? We'll look into it. |
I haven't yet tested personally. Thanks! |
I am now checking whether the image ID is actually being stripped out on import or when the site goes Atomic. As that could be where the issue is introduced as well. 🤔 |
I can confirm that when we import content from Substack, the imported posts don't include the full Image markup. Here's how imported post with one Image block looks like: <!-- wp:image {"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="here-was-the-image-url" alt="" /></figure><!-- /wp:image --> Instead, it should look like: <!-- wp:image {"id":2152,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="here-was-the-image-url" alt="" class="wp-image-2152" /></figure><!-- /wp:image --> In other words, what is missing is the image ID and also the class. If both are present, the image will be picked up as a Featured image correctly. When testing the import from Medium, the imported content looks as follows: <figure><img data-width="3672" data-height="3096" src="https://cdn-images-1.medium.com/max/800/1*mmPxZftrwj4bmIaDR_zBNQ.png"></figure> The Image block isn't used at all, neither the image itself is imported to the site. What we may want to do is to either A) adjust how the importers work - or - B) change the way the image is picked up from the post content. When looking at why the image is not loaded on the Posts page in Calypso for instance, the reason is that the const candidateImage = find( post.content_images, isCandidateForCanonicalImage ); This happens because export function isCandidateForCanonicalImage( image ) {
if ( ! image ) {
return false;
}
if ( image.width < 100 ) {
return false;
}
if ( image.width * image.height < 100 * 75 ) {
return false;
}
return true;
} But as soon as the image in the post content has correct markup, the I think it might make more sense to fix the importers to make sure the imported content has proper markup instead of trying to make the rest of the system be able to read images from the content that don't have correct markup. What do you folks think? |
Is this lib used in Gutenberg editor, or somewhere else? I didn't quite follow that bit.
This would help things also when they don't use Calypso, correct? @vishnugopal there's an issue with image IDs not getting assigned with Substack content importer. (Things work with Medium). Could the team look into that? Could the issue exist in other content importers as well? I think the lack of ID causes other issues as well, like how the images get optimized by Photon or Jetpack's lightbox feature. (Haven't tested, tho)
@ivan-ottinger why would the featured image depend on width/height, would anything break if that limitation is removed? |
Thanks, Mikael!
I don't think the If the Image block doesn't have the proper markup, Calypso won't consider it at all. That is because the wp-calypso/client/lib/post-normalizer/rule-content-detect-media.js Lines 139 to 172 in 7fe8ab0
Looking at the related code in Calypso, I believe the width/height check (in I did not dig deeper into the code to see exactly why incomplete Image block markup prevents the "Automatically use first image in post" setting from working properly because correcting the block markup fixes the issue everywhere. Once the correct markup is used, the image starts displaying on the Post page in Calypso, but also in the front-end on pages where the image is displayed thanks to that "Automatically use first image in post" setting):
Apart from the image ID, there should be the image CSS class as well, e.g. <!-- wp:image {"id":2152,"sizeSlug":"large","linkDestination":"none"} --><figure class="wp-block-image size-large"><img src="here-was-the-image-url" alt="" class="wp-image-2152" /></figure><!-- /wp:image --> When both are present, Calypso can pick up the height / width of the image correctly. Also, the "Automatically use first image in post" setting will work as expected again. Simple sites are more forgiving than Atomic in a way that even with the incomplete Image block markup, the "Automatically use first image in post" setting will still work as expected. If the image ID is missing on an Atomic site, the image simply won't load (the behaviour will be basically the same as if the "Automatically use first image in post" setting was disabled). This is the case the user encountered. Again, I haven't dug deeper since completing the Image block markup solves the issue. But if needed, I can check how exactly is the incomplete block markup related to the "Automatically use first image in post" setting. I can imagine it could also be something with Photon - as you mention in your previous comment. Also, I think it is worth mentioning that both image ID and related CSS class are part of the Image block markup in WordPress core (I have checked this on a self-hosted WPORG site without Jetpack or anything WordPress.com related). That's why I believe we should try to get it correctly when importing content. And I am hoping I didn't miss anything. 🙂 Please let me know if something isn't clear. |
@ivan-ottinger, can you please review this issue and let us know the next steps? It feels like this may have been deprioritised in favour of Developers Developers Developers. |
Thank you for the ping, @inaikem! I was AFK so getting to your message just today.
The next step is to make sure the Substack importer (https://wordpress.com/import/) produces correct markup for Image blocks. Here is a specific example: Image imported from Substack currently:
How it should be imported instead:
The only difference between the two is that the correct markup includes
As soon as the markup is correct, the Does that make sense? Please let me know if you have any questions. Happy to clarify! 🙂 |
Thank you! Do you have a sense of priority for getting this change shipped given the focus on inbound migrations and customer acquisition? |
The content with images is imported without any errors and images are loading properly in both frontend and the block editor. The issue affects those users who:
However, the setting is available only in Customizer of a small fraction of old non-block-based themes like
|
Actually, turns out the issue is still reproducible, but manifesting on Atomic sites only. I am reopening the issue again and leaving its priority as I have also updated my previous comment. |
Repoted at p1704606505767399-slack-C02NQ4HMJKV:
The text was updated successfully, but these errors were encountered: