Change attachment size for sharing on social media in All in One SEO Pack

By default, when All in One SEO Pack shares your post image attachment with social media networks such as Facebook or Twitter via Opengraph, it uses the large version. You can change the size using our aioseop_attachment_size filter hook.

add_filter( 'aioseop_attachment_size', 'change_aioseop_aioseop_attachment_size_size' , 10, 1);

function change_aioseop_aioseop_attachment_size_size( $size ){
return 'medium';

The built-in sizes are thumbnail, medium, and large. If you have a custom image size, you can use that too.

add_image_size( 'custom_image_size', 385, 248, true );

add_filter( 'aioseop_aioseop_attachment_size', 'change_aioseop_aioseop_attachment_size', 10, 1);

function change_aioseop_aioseop_attachment_size( $size ){
return 'custom_image_size';

Skip to toolbar