• Resolved Ectropy

    (@ectropy)


    Is there a way to exclude specific images from being considered as potential meta property og:image images.

    When I choose to enable the “Social Image Settings” “Output multiple Open Graph image tags” setting, The SEO Framework will sometimes choose images that are not appropriate for inclusion in a preview. Is there a way to exclude specific images?

    I’d love to keep this setting enabled because in many cases it works well. A way to exclude certain images would allow me to keep using the “Output multiple Open Graph image tags” setting.

    Thanks in advance for any light you can shed on this question!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    Which images does TSF take that aren’t appropriate? Do you have an example (link)?

    Its ‘AI’ only went through one manual iteration thus far; it’s currently able to avoid including form button images, tracking pixels, scripts, etc. We may, with some help (and data!), improve it further 🙂

    In any case, you can exclude images by filtering the found image details. It requires some PHP knowledge to configure it well. This snippet should help you get started:

    add_filter( 'the_seo_framework_image_details', function( $details ) {
    
    	foreach ( $details as $i => $detail ) {
    		// Exclude by URL-part.
    		if ( false !== strpos( $detail['url'], 'exclude-this-image.jpg' ) ) {
    			unset( $details[ $i ] );
    		}
    		// Exclude by ID.
    		if ( 42 === $detail['id'] ) {
    			unset( $details[ $i ] );
    		}
    	}
    
    	return $details;
    } );
    Thread Starter Ectropy

    (@ectropy)

    Thanks for your response and your snippet! I think I’ll be able to use it to accomplish what I want.

    The image in question that would sometimes be chosen was an icon in PNG format with transparent background. (https://dev.rhinehartphotography.com/wp-content/uploads/2020/10/rotatephone-white.png) I assume sometimes people would want images with transparent backgrounds to be selected, but in my instance it wasn’t the best choice available on the page.

    Plugin Author Sybre Waaijer

    (@cybr)

    Thanks for that! I just took a peek at the site, and I’m not sure if we can find a way programmatically to exclude such an image without affecting performance… unless we add more toggles, are able to read content-images metadata, and inspect their sizes.

    All these things are planned for future releases, but we’re not quite there yet. I hope the filter suffices until then! Cheers 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Exclude specific image(s) from og:image’ is closed to new replies.