Advanced Image Handling in Feed to Post (via Filters)

This article is about image importing and handling for the Feed to Post add-on.

It lists a number of code snippets that can be used to alter the way images are handled by WP RSS Aggregator.

Remove All Images from the Post Content

There are two ways to achieve this.

  • Set up an extraction rule as follows:  “img”, “Remove Element”
  • Use this filter: add_filter('wprss_ftp_strip_images_from_post','__return_true');

Only Keep Images In the Post Content

There are two ways to achieve this.

  • Set up an extraction rule as follows:  “img”, “Keep only the matched element(s)”
  • Use this filter: add_filter('wprss_ftp_images_only_in_post_content','__return_true');

Import the Featured Image into a Post's Custom Field

If your theme looks for the featured image in a custom field, rather than using the WordPress standard featured image, you can use any of the two filters below.

The first will save the URL of the image, while the second will save the ID of the image attachment. You will need to check which of the two your theme needs. If you are unsure, you can use both.

Save the  URL in a meta field:

add_filter( 'wprss_ftp_featured_image_meta', 'save_url_custom_field' );
function save_url_custom_field() {
  return 'my_meta_key'; // Replace with name of desired meta key

Save the  ID in a meta field:

add_filter( 'wprss_ftp_featured_image_meta_id', 'save_id_custom_field' );
function save_id_custom_field() {
  return 'my_meta_key'; // Replace with name of desired meta key

Disable All Feed Source's Fallback Featured Image

If you do not want to use the fallback featured image for those feed items that do not have their own image, use the below code snippet.

You may also uncheck the option titled “Fallback to feed image” within Feed to Post’s general Images settings.

add_filter( 'wprss_ftp_feed_image_fallback', '__return_false', 100 );

Exclude specific sources from this filter

In the example below, the feed sources that are listed in the code (11, 12, and 13) are the feed sources that will use a fallback image while all others will not.

add_filter( 'wprss_ftp_feed_image_fallback', 'wprss_enable_fallback_images', 100 );
function wprss_enable_fallback_images() {
    return array(

Apply this filter to only specific sources

In the example below, the feed sources that are listed in the code (123, 456, and 789) are the feed sources that will not use a fallback image while all others will continue to use one.

add_filter( 'wprss_ftp_feed_image_fallback', 'wprss_enable_fallback_images', 100, 3 );
function wprss_enable_fallback_images( $enable, $post, $source_id ) {
    $disable_for_sources = array(

    if ( in_array( $source_id, $disable_for_sources ) ) {
        return false;
    return $enable;

Enable the Feed Source’s Fallback Featured Image For Selected Feed Sources

You can also enable the use of the feed source’s fallback image for specific feed sources. This is done by using the filter below to return an array of the IDs of the feed sources that should use the feed source’s fallback image. Change the IDs to the IDs of your own feed sources.

add_filter( 'wprss_ftp_feed_image_fallback', 'my_function' );
function my_function( $enable ) {
    return array( 34, 118, 17 );

If Your Images are Not Deleted when Posts are Deleted, Try This

Whenever a post is deleted, WordPress will automatically check if there are any images that were attached to the deleted post. If after deleting the posts, there are images that are now attached to nothing, they will be deleted too.

In some rare cases, typically due to conflicts with other plugins/themes, the images are not deleted and are left unattached in your gallery. You can force Feed to Post to delete the attachments manually when deleting posts by using the filter below.

add_filter( 'wprss_ftp_delete_attachments_with_posts', '__return_true' );<br>

Fixing Issues with the Error Log Showing “Sorry, this file type is not permitted for security reasons”

This error appears in the plugin’s Error Log when an image was not imported due to WordPress’ security check for the image’s extension. Some sites will deliver images without extensions in the URL, but will still send the correct MIME type.

The filter below will allow the plugin to bypass this security check and import all images.

add_filter( 'wprss_ftp_override_upload_security', '__return_true' );<br>

How do I add this to my site?

Follow the step-by-step instructions below to add this filter to your WordPress site.

  1. Copy the code you need from above.
  2. Go to your WordPress site's dashboard.
  3. Go to Plugins > Add New.
  4. Search for Code Snippets, then install and activate the plugin.
  5. Once installed and activated, go to Snippets in your dashboard menu.
  6. Click on Add New.
  7. Add a Title, which could be the title of this article.
  8. Paste the code you copied in step 1 to the Code section.
  9. Add a Description or Tags if you wish to do so. It is not required.
  10. Click on Save Changes and Activate to save the filter and activate it.
    1. Or click on Save Changes to save the filter and activate it later.
  11. Your action or filter is now stored and active on your site.

Still need help? Contact Us Contact Us