Support » Plugin: Feed Post Thumbnail » Modyfying URL of an image

  • I have tried to find a hook to easily modify the URL of the image, but – I believe – I would have to write the whole add_feed_item_media function. Or, but this I am not certain of, just write a proper hook for add_feed_item_media.

    Can you, please, advise on the correct approach here? I am Golang/Java developer, PHP is a bit awkward for me after so many years of not using it…

    Rationale – I have a server with a heavy hotlinking config going on, so I need to modify the URL of images to bypass that “shield” for feed users.

    The simplest way I can see is to add one additional hook and two lines of code to this plugin. Happy to share a patch if you would like to use that – I am certain a lot of people can benefit from that, especially using hotlinking prevention (i.e. CloudFlare users…)

    • This topic was modified 3 months, 1 week ago by lukaszrzanek. Reason: Added rationale for my question and possible solution
Viewing 1 replies (of 1 total)
  • Plugin Contributor Ulrich

    (@grapplerulrich)

    Hi Łukasz

    I hope you were able to find a solution. If not here is how you could do it:

    add_filter(
    	'wp_get_attachment_image_src',
    	function( $image ) {
    		if ( doing_action( 'rss2_item' ) ) {
    			// Modify URL in $image[0].
    			return $image;
    		}
    		return $image;
    	}
    );

    This is not this plugin specific but to WordPress in general.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.