Docs    Facebook    Customizations

Specifying exact image sizes using the cff_resized_image_sizes filter

Facebook only returns large images for timeline feeds. How to set your own resized image sizes with a filter.

Would you like to choose the sizes of the images that Facebook Feed Pro creates for your feed?

Requirements: The cff_resized_image_sizes filter is part of Facebook Feed Pro.

Facebook only provides large image sizes for timeline posts. A feed can end up loading images that are much larger than it needs.

To avoid that, the plugin can create smaller copies of the images and store them on your server. It then shows the smallest one that fits your feed. In this guide, we’ll show you the default sizes and how to add your own.

Before you get started, make sure Facebook Feed Pro is installed and activated on your WordPress site.

Here is what we will cover.

The Default Image Sizes

The plugin creates its copies at 400 and 250 pixels wide. When the GDPR features are on, it also creates a 700 pixel version. They are on when the GDPR setting is Yes, or Automatic with a supported consent plugin active.

Resizing only happens when the Optimize Images setting is on.

To find it, go to Facebook Feed » Settings and click the Advanced tab. The toggle in the Optimize Images box turns the feature on or off. It stays on, and you can’t turn it off, unless the GDPR setting on the Feeds tab is set to No.

If Optimize Images is off, the plugin doesn’t create these copies and the filter has no effect.

The plugin is smart about what it stores on your server. It only makes copies of images where Facebook doesn’t already provide a medium-sized version. With the GDPR features on, it makes copies for every post.

The plugin saves the copies in your site’s uploads folder, in a folder called sb-facebook-feed-images. Each copy is made from the largest version of the image that Facebook provides.

Adding Your Own Image Sizes

The filter passes the list of sizes to your code as an array of widths in pixels. Your code returns the list you want the plugin to use.

The following snippet makes the plugin create 300 and 500 pixel copies.

add_filter( 'cff_resized_image_sizes', 'my_cff_resized_image_sizes' );
function my_cff_resized_image_sizes( $image_sizes ) {
	return array( 300, 500 );
}

To add a size and keep the defaults, add your width to the array instead.

add_filter( 'cff_resized_image_sizes', 'my_cff_resized_image_sizes' );
function my_cff_resized_image_sizes( $image_sizes ) {
	$image_sizes[] = 600;
	return $image_sizes;
}

Both snippets use the same function name, so use only one of them. Then add it with a code snippets plugin such as WPCode, as a PHP snippet.

The new sizes apply to images the plugin copies from then on.

To make the plugin copy your existing images again, go to Facebook Feed » Settings and click the Advanced tab. Next, click Reset next to the Optimize Images toggle. This clears the saved copies, and the plugin creates new ones in your sizes once the feed updates.

That’s it! You now know how to choose the exact image sizes your Facebook feed creates.

Frequently Asked Questions

Below, we’ve answered some of the most common questions about image sizes in a Facebook feed.

Why doesn’t my feed use the new sizes?

The plugin remembers the sizes it used for each image it has already copied. To fix this, click Reset in the Optimize Images box on the Advanced tab so the plugin creates new copies in your sizes. Also check that the Optimize Images toggle is on. Images where Facebook already provides a medium-sized version don’t get copies at all, unless the GDPR features are on.

support

Couldn’t find your answer in the docs?

Contact Support