• This is an awesome plugin. Thank you!

    I have a minor problem. I am happy to solve it myself, I just need to be pointed in the right direction.

    I upload hundreds of photos to my WP blog, and WP-Offload-S3 uploads it to my PHOTOS bucket on S3, then it becomes visible via my CDN subdomain, delivered really quickly to my users.

    BUT sometimes I don’t want images to be cached via Cloudfront – because of the cost. Sometimes I publish an animated GIF which might be several MB in size. View that a few thousand times and I have to pay for several GB of Cloudfront bandwidth. Multiply that by a few dozen GIF’s and the cost mounts up.

    For these GIF’s I’d like to be able to change the IMG SRC from CDN.MyDomain.com to PHOTOS.MyDomain.com and have that URL remain as is – rather than have WP-Offload-S3 change it for me.

    In my situation, the simplest way would be to edit the code somewhere to specify a condition like:
    IF File Extension == “GIF” THEN
    DO NOT REWRITE URL
    ELSE
    REWRITE URL

    Where would I make this change?
    Is there a better way of achieving this?

    I’d rather not maintain a separate S3 bucket, if possible. Otherwise I’d have to upload the GIF’s to S3 directly, bypassing the WP Media Library, which is not ideal.

    Thanks in advance for your help.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • I thought I could implement this by putting a NOCACHE query string in the IMG SRC attribute, then change the “url_needs_replacing” function to ignore anything with “NOCACHE” in the URL

    So it would ignore anything like this:
    <img src="https://photos.MyDomain.com/BigImage.GIF?NOCACHE" />

    url_needs_replacing would have something like:

    if (strpos($url, '?NOCACHE') !== false) {
        return false;
    }

    Is this the simplest / safest way to do it?

    • This reply was modified 8 months, 1 week ago by  Neilius.
    Plugin Contributor ianmjones

    (@ianmjones)

    It’s not super clear to me whether you want those gifs offloaded or not?

    If not, check out the Tweaks plugin, specifically the as3cf_pre_update_attachment_metadata filter.

    https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks/blob/3e83234e96f67b823ae94d27385cf9603d149c0b/amazon-s3-and-cloudfront-tweaks.php#L97

    If you do still want them offloaded (maybe for backup), then you can change the URL created by WP Offload S3 with either the as3cf_wp_get_attachment_url or as3cf_get_attachment_url filters (found in the same Tweaks plugin linked above).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘More control of rewrite URL option’ is closed to new replies.