Feature Request: Filter for image src (can then use Jetpack’s Photon CDN & more)

Home Forums AdRotate for WordPress General Support Feature Request: Filter for image src (can then use Jetpack’s Photon CDN & more)

This topic contains 5 replies, has 2 voices, and was last updated by  KZeni 1 year, 3 months ago.

  • #39647


    I want seamless integration of Jetpack’s Photon CDN service with the images served by AdRotate, but it appears there currently isn’t any filters which make it possible to update the image URL used by an ad. I’ve come up with a patch to add in this functionality, and I would love to see it adopted in the next official version for others to make use of.

    There’s only one line needing to be added to the plugin to accommodate this, but I’ll show more code for context. Open adrotate-output.php and update it so there’s a new line with the apply_filters function as seen here:

    $image = apply_filters('adrotate_image_src',$image);
    $banner_output = str_replace('%title%', $name, $banner_output);
    $banner_output = str_replace('%random%', rand(100000,999999), $banner_output);
    $banner_output = str_replace('%asset%', $image, $banner_output); // Replaces %image%
    $banner_output = str_replace('%image%', $image, $banner_output); // Depreciated, remove in AdRotate 5.0
    $banner_output = str_replace('%id%', $id, $banner_output);
    $banner_output = do_shortcode($banner_output);

    Again, it’s just that one line that needs to be added, but I included the rest for context to see what it’s affecting.

    Feel free to include this in the next version of AdRotate. I would greatly appreciate it and I’m guessing others will as well.

    Thanks for the great plugin!

    Also, I’ve crossposted this to WP.org support forum for others to potentially find it, if needed: https://wordpress.org/support/topic/feature-request-filter-for-image-src-can-then-use-jetpacks-photon-cdn-more/



    Oh, and here’s the code I added to my theme’s functions.php file to make use of that new filter so all images used by AdRotate are automatically passed through the WP.com CDN via Jetpack’s Photon feature (when available).

    // Send images in AdRotate through Jetpack's Photon CDN service
    function adrotate_apply_jetpack_photon($image){
    		return jetpack_photon_url($image);
    		return $image;

    This would otherwise not be possible without this filter being added. Keep in mind that this will stop working if AdRotate is updated without including this new feature (as it will overwrite the patch adding the new filter).



    So it’s 9 lines 😉

    I’ll look into it and consider it for a future update.



    Thanks! It’d be very appreciated!




    Great! Thanks a bunch!

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Feature Request: Filter for image src (can then use Jetpack’s Photon CDN & more)’ is closed to new replies.