Support » Plugin: The SEO Framework » Specify og:image

  • Hello, i’ve just switched to SEO Framework from Yoast and i have to say i’m impressed so far!

    I’ve managed to move all settings to SEO Framework, the only thing i don’t know how to do is how to make the plugin use a specific size for og:image.

    I have created an image size in my functions:
    add_image_size( 'fn-og', 1200, 630, true ); // Hard Crop Mode

    Now i want to make the plugin to use that specific image size for og:image.

    With yoast i could do this:

    add_filter( 'wpseo_opengraph_image_size', 'ac_wpseo_image_size', 10, 1 );
    
    function ac_wpseo_image_size( $string ) {
    	
    	return 'fn-og';
    
    }

    is there an alternative function for the SEO Framework?

    • This topic was modified 7 months, 3 weeks ago by Inje.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    I’m glad you like the plugin!

    Now, I haven’t ever tested this, but I believe this should do what you want:

    add_filter( 'the_seo_framework_og_image_args', function( $args ) {
    
    	$args['size'] = 'fn-og';
    
    	return $args;
    } );
    

    Please note that I’m about to overhaul the image generation functions, and I’ll dump that filter aside for newer and better ones. What this yields and whether this change will directly affect the filter above is still to be determined. For more information, see this GitHub issue.

    Moreover, note that Facebook and other social networks already crop the image for you. So, it’s essentially wasted space on your server to do this preemptively.

    Hello Sybre, first of all thank you for your reply, but that didn’t work 🙁

    The reason i want to do this is because i apply a watermark on fn-og, to be shown as a shared image on facebook. It has nothing to do with the image size.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again, Inje,

    I rechecked the code, and the filter above only works when the image is taken from a default WordPress field; specifically, the featured image field.

    Unfortunately, for any other fields, hijacking the image size isn’t easy. The image file selection and our custom cropper (which we had to reroute due to a bug in WordPress) handle this only once for the best size available for Facebook (4096×4096), and then it’s no longer processed; which significantly improves performance.

    Now, you could look into a custom function that reroutes The SEO Framework’s custom fields to your watermarked images at the moment a post is saved or updated. But, I doubt this is worth your time–especially since I’m going to rework the image generation process in the next update.

    With that said, I will keep your use-case scenario in mind for the next version. May I be able to add something of use for you there, then you’ll find it in the updated API docs, which will be released together with the new version. Don’t forget to reach out to me after v3.3.0’s release so that I can help you with this–ETA northern hemisphere’s summer.

    I added a comment to the issue as a reminder: https://github.com/sybrew/the-seo-framework/issues/403#issuecomment-485052163

    I’m sorry I can’t help you any further on this part right now! The software’s almost at its peak, and this is the final piece that needed necessary work… I’m ultimately glad you bumped into this issue before I started reworking! 🙂

    Glad i could “help” 🙂

    Thank you for your work. I will wait for an update.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Specify og:image’ is closed to new replies.