Broadcasted attachments W3TC CDN
-
I have CloudFront CDN (push) enabled on W3 Total Cache. When I add an image to my media library, the image is uploaded to the CDN and displays correctly on my blog.
When I broadcast a post that has image attachments with ThreeWP Broadcast, the new attachments aren’t being picked up by W3TC and so aren’t being uploaded to the CDN and we get 404’s on our site as a result.
Looking in /path/to/wp-content/plugins/w3-total-cache/lib/W3/Plugin/Cdn.php I see
add_filter('update_attached_file', array( &$this, 'update_attached_file' )); ... function update_attached_file($attached_file) { $files = $this->_get_common()->get_files_for_upload($attached_file); $files = apply_filters('w3tc_cdn_update_attachment', $files); $results = array(); $this->_get_common()->upload($files, true, $results); return $attached_file; }
I believe your
copy_attachment
method in /path/to/wp-content/plugins/threewp-broadcast/ThreeWP_Broadcast.php needs to trigger this filter by callingupdate_attached_file
below yourif ( $o->attachment_data->file_metadata )
check.I haven’t tested, but perhaps:
// 3. Overwrite the metadata that needs to be overwritten with fresh data. $this->debug( 'Copy attachment: Updating metadata.' ); wp_update_attachment_metadata( $o->attachment_id, $attach_data ); } update_attached_file($o->attachment_id, $target);
- The topic ‘Broadcasted attachments W3TC CDN’ is closed to new replies.