Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I just setup W3 Total Cache S3 CDN (origin push) and most of the URLs are being rewritten correctly but we have some custom plugins where the URLs are not being rewritten. How do I grab the rewritten URL of W3TC from another plugin? I'm currently using the following code to grab the image:

wp_get_attachment_image_src( get_post_thumbnail_id(), 'car-thumb');

I'm assuming there is a filter of some sort that just replaces the original "origin" url with the asset URL on the S3 bucket but I've been unable to find where in the code.

share|improve this question

1 Answer

I had the same issues and couldn't get an answer either. I did however find where in the database WP is storing the entries for the attached images and used that to create my own rewritten URLs.

If you look in the _postmeta table there is a meta_key "_wp_attached_file" that stores the folder path to the attached images. With this information I only needed to add the URL structure for where our S3 bucket is located.

global $postid;
$bucketName = "your_bucket_name_goes_here";
$postThumbNailID = get_post_meta($post->ID, '_thumbnail_id');
$postThumbNailUrl = get_post_meta($postThumbNailID[0], '_wp_attached_file');
$s3BucketURL = "http://".$bucketName.".s3.amazonaws.com/files/".$postThumbNailUrl[0];
share|improve this answer
Where did you put this code? This doesn't look like a complete solution to me. – s_ha_dum Feb 14 at 20:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.