• Resolved peterlanephotography

    (@peterlanephotography)


    If you use Divi theme or similar (hundreds of thousands use it), you can see that your gallery images are not detected by Yoast sitemap. It is a very annoing old problem that Yoast ignores for very long time. Strange attitude for SEO plugin that works against SEO … Jetpack sitemap reads gallery images in other themes, why Yoast doesn’t?

    I hope you’ll either give us a copy/paste code for functions.php or just update your plugin and make it work.

    Thank you in advance!

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter peterlanephotography

    (@peterlanephotography)

    As an update:

    to replicate it on your end here the setup.

    Jetpack acceleration is used which is I think so called Photon CDN, which puts i0.wp… before the image url.

    – if default theme is used – all good
    – if Divi theme used with standard WP editor – all good
    – if Divi builder used for page creation – problem! No images in sitemap.

    I’m 4 days emailing back and forth to Yoast – Jetpack – Divi support to find a solution and everybody says go to other two, not our problem. But the problem do exist. It’s not about a problem in someone’s code but a lack of collaboration in favour of the end user, to make things done as none of you 3 offer all services in house.

    Thanks in advance.

    Sa?a

    (@stodorovic)

    It should be fixed in Divi builder. They have tried quick workaround for this issue, but it could create more side effects. You could try code from Page or post sitemap rendering is taking too much time, but it’s problematic related to performance (because it’ll run all shortcodes in all pages). If you don’t have too much pages, maybe it could work.

    Thread Starter peterlanephotography

    (@peterlanephotography)

    The problem is that sitemap can’t see the code behind Divi builder code. Yoast suggested an example code that I changed with my website (maybe wrong) but it’s still not working:

    function wpseo_cdn_filter( $uri ) {
    return str_replace( ‘https://peterlanephotography.co.uk’, ‘https://i0.wp.com/peterlanephotography.co.uk’, $uri );
    }
    add_filter( ‘wpseo_xml_sitemap_img_src’, ‘wpseo_cdn_filter’ );

    I added https://i0.wp.com/ as this is the extra code that comes from Jetpack Photon CDN on each photo url.

    @peterlanephotography

    We would like some more information.

    1. Can you confirm you are using the most recent Yoast SEO, v12.4? If you update, does the issue resolve?

    2. Are all your non-Yoast plugins and themes also updated?

    3. How are you adding images on the pages/posts in question? Are you adding them as a featured image, as an image gallery or through some kind of Divi module? If you are using a Divi module, which one? An image module, text module some other kind?

    4. Can you provide an example post/page that has the images which are not appearing on the sitemap?

    Thread Starter peterlanephotography

    (@peterlanephotography)

    1/ yes, the newest

    2/ all

    3/ just a normal gallery (with the added by Jetpack option – tiled gallery), random order, full size images

    4/ any of the pages on my site, under photography menu dropdown incl index page

    P.S. regarding the code above, it can’t work as the Jetpack image acceleration service (former Photon) uses multiple address before the actual image url, for example https://i0.wp.com, https://i1.wp.com, https://i2.wp.com

    But I think the issue is not in the CDN image detection as if the page is not build by Divi builder, the sitemap works fine with Jetpack image acceleration.

    Plugin Support amboutwe

    (@amboutwe)

    This was reported, investigated, and Divi released a fix (in 2017) that parsed Gallery images for inclusion in the sitemap.

    https://github.com/Yoast/wordpress-seo/issues/4808

    As the fix was part of the Divi code, please reach out to their support team to confirm that they are still integrating gallery images with our sitemap. If they are integrating and the code is not working, they can investigate their integration and fix, as needed.

    Thread Starter peterlanephotography

    (@peterlanephotography)

    I have 10 emails from them and in the end they say: go to Yoast. Now you say: go to Divi.

    How about if you fix it together and skip the middle man? I can give you their support emails. How about that? Honestly I don’t see another way as currently we move into a dead loop.

    Thanks

    Sa?a

    (@stodorovic)

    It seems that images from Tiled Galleries (Jetpack) are removed. It’s probably a conflict between JetPack and Divi. I could try to check more details. It’s possible that images are removed as “external” because Divi expands shortcodes to HTML code before JetPack processes galleries. I think that you should move replacing URLs before sitemap image parser removes it as “external”. It could be done in filter wpseo_sitemap_content_before_parse_html_images (after Divi runs shortcodes).

    Please send more details about gallery shortcode. I’ll try to make better PHP snippet.

    Sa?a

    (@stodorovic)

    It’s possible to disable JetPack for sitemap requests by filter jetpack_photon_skip_image. Something like this:

    add_filter( 'wpseo_build_sitemap_post_type', function( $type ) {
            add_filter( 'jetpack_photon_skip_image', '__return_true' );
    
            return $type;
    } );
    
    Thread Starter peterlanephotography

    (@peterlanephotography)

    Hi Sasa,

    I tried the code and restarted the sitemap but still with no result. I think your thoughts go in the right direction and we have to dig in that.

    The gallery shortcode is simple: [gallery type="rectangular" size="full" link="file" ids="35173,35174,30593,30507,30386,25740,25734,25566,25550,25445,25328,24889,24844,24650,24594,24584,24522,24510,24482,24479,24454,24471,24448,24442,24411" orderby="rand"]

    I suppose Yoast parses the page code before Divi builder to push the code and that’s the reason. If you use same code on a standard editor page everything works fine. Another thing is – individual (not in gallery) images used in Divi builder page do appear in the sitemap, so no conflict between Yoast, Divi builder and Jetpack here. Where is the catch? You can test on your site.

    Thank you for dedicating time for this!

    P.S. I’m not a coder so if you prepare a function.php filter code I can only copy/paste ??

    Sa?a

    (@stodorovic)

    I think that I know what’s happening. I don’t have Divi builder, but I can simulate their sitemap integration. There is filter wpseo_sitemap_content_before_parse_html which Divi developers use to convert shortcodes to plain HTML. It runs before any parsing of the post. Also, it can be slow because all shortcodes (not only Divi) from all pages are processed.

    I’ll try to explain my suspicion. Filters run in this order:

    • Filter wpseo_sitemap_content_before_parse_html runs if Divi builder is installed. In this case (if Divi builder detects usage of their shortcodes), all shortcodes (including gallery shortcode) are converted to HTML. Otherwise (Classic/Gutenberg editor), gallery shortcode isn’t touched.
    • WPSEO_Sitemap_Image_Parser parses HTML and it ignores images which don’t contain hostname (i0.wp.com/… contains this string, so it isn’t root of cause) or contains query strings (I see w, h and ssl in image URLs – which could be reason). Filter wpseo_xml_sitemap_img_src runs for found images at the end of process.
    • WPSEO_Sitemap_Image_Parser parses gallery shortcodes and it retrieves all image IDs from attributes. Filter wpseo_xml_sitemap_img_src runs for found images at the end of process.
    • Filter wpseo_sitemap_urlimages runs. Images aren’t included if Divi has already converted gallery shortcode (in first step).

    Possible solutions:

    • Remove gallery shortcode for sitemap requests.
    • Use filter pre_do_shortcode_tag to prevent convertion of galleries.
    • Use wpseo_sitemap_content_before_parse_html with higher priority then Divi builder to “sanitize” image URLs.

    I’ll try to create some PHP snippet soon (when I find most efficient solution).

    Thread Starter peterlanephotography

    (@peterlanephotography)

    Let me know if you need a copy of Divi

    Sa?a

    (@stodorovic)

    I think that I’ve older version of Divi Builder (there aren’t changes related to the sitemaps). Anyway, it’s possible to simulate it with following code:

    add_filter( 'wpseo_sitemap_content_before_parse_html_images', function( $content ) {
            return apply_filters( 'the_content', $content );
    } );
    

    I’ve created filter which prevents “conversion” of gallery shortcode. It works in my simulation of your issue.

    add_filter( 'wpseo_build_sitemap_post_type', function( $type ) {
    	add_filter( 'jetpack_photon_skip_image', '__return_true' );
    	add_filter( 'pre_do_shortcode_tag', 'my_sitemap_shortcode_filter', 10, 4 );
    
    	return $type;
    } );
    
    function my_sitemap_shortcode_filter( $content, $tag, $attr, $m ) {
    	if ( $tag === 'gallery' ) {
    		$content = $m[0];
    	}
    
    	return $content;
    }
    

    Please purge OPCache (ask host if you don’t know how to do it) and other caches after you add it into functions.php. Also remove previous code to we avoid possible conflicts.

    It’s possible that there is other plugin/code/… which adds query string (height/width/ssl) in img src, but previous code disable JetPack/Divi code if it’s sitemap request (and Yoast uses standard way to obtain IDs from gallery shortcode).

    Thread Starter peterlanephotography

    (@peterlanephotography)

    I added the code (the last one, second one) to functions.php, reset the map and cleaned cache, but still the same… no luck.

    Thread Starter peterlanephotography

    (@peterlanephotography)

    I think we have to exclude Jetpack from the brainstorm as I made an experiment with another site.

    With default theme the sitemap is OK, with or without Jetpack. With Divi build pages no images in sitemap, with or without Jetpack.

    So, where’s the catch between Yoast gallery detection and Divi code …

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Yoast sitemap ignores gallery images if themes/builders used’ is closed to new replies.