• Resolved bonumaster

    (@bonumaster)


    Hello. Thank you for this wonderful plugin. It works! But I have some questions and clarifications that only you can help me to understand.

    1. When medias are already offloaded/served through CDN(DigitalOcean) and it works perfectly with the Rewrite Media URLs, If we try to modify the attachment/media. (We are watermarking the media’s even it is offloaded because we didn’t delete the file in our server after offloading). Will it replace the file uploaded in the CDN? or It will ignore in offloading? Will this plugin replace existing files if media is modified or we need to manually delete it in our DigitalOcean space? Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Delicious Brains

    (@deliciousbrains)

    Hi @bonumaster, thanks for the kind words, much appreciated.

    > Will it replace the file uploaded in the CDN? or It will ignore in offloading? Will this plugin replace existing files if media is modified or we need to manually delete it in our DigitalOcean space?

    WP Offload Media should re-offload the images after they have been processed, but it does depend on whether the watermarking process calls one of the functions that triggers the re-offload.

    If it’s your own custom code that does the watermarking, then please ensure that after the files for a Media Library item have been processed that your code does something like the following…

    wp_update_attachment_metadata( $item->ID, wp_generate_attachment_metadata( $item->ID, $file ) );

    The important call there is wp_update_attachment_metadata(), if you already have the attachment’s metadata you don’t need to regenerate it, just pass it in.

    WP Offload Media will see the wp_update_attachment_metadata filter fired by the function of the same name, and copy the attachment’s file to the bucket, overwriting the previous versions if already offloaded.

    I would recommend using the as3cf_pre_upload_attachment filter to cancel the original offload though, and then remove that filter before doing the final wp_update_attachment_metadata. That way you don’t waste time offloading to the bucket and re-offloading again, and it ensures CDNs only see the final watermarked files.

    https://deliciousbrains.com/wp-offload-media/doc/developer-guide/#automatic-offload-hooks-wp-update-attachment-metadata

    https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks/blob/beb2e0f1bba71be7b462a60209e5ff630a57437e/amazon-s3-and-cloudfront-tweaks.php#L528

    If you’re using a watermarking plugin, might be worth passing the above info onto the author if you’re seeing issues.

    -IJ

Viewing 1 replies (of 1 total)
  • The topic ‘Replace Media’ is closed to new replies.