9. Offload Media Pro Issues

9. Offload Media Pro Issues

Thumbnail “Greyed Out”

Ian at DeliciousBrains support:

Hi Larry,

So, your example URLs return a “No such key” error, but … tada!:- https://cdn5.larrymanchester.com/2020/02/03144248/www-Img-2015-04-21_1-200×300.jpg

It looks like you’re using a CloudFront distribution that uses an offset prefix into the bucket as its source, e.g. the “cdn5.larrymanchester.com” distribution is using an origin that has an “Origin Path” of “LSM”.

You can tell WP Offload Media about this offset by using the “as3cf_cloudfront_path_parts” filter:-

https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks/blob/96d9fc03ffcfdc1d2e77b0a1a53891e6e1a76e30/amazon-s3-and-cloudfront-tweaks.php#L830

If you download, install, and edit the Tweaks plugin, and then change that linked example function to look for “cdn5.larrymanchester.com” and “LSM” instead of “cdn.example.com” and “media” respectively, you should be good to go. Please remember to uncomment the associated “add_filter” line in the __construct function too.

Please get in touch if there is anything else I can help you with.

Cheers,
Ian


https://github.com/deliciousbrains/wp-amazon-s3-and-cloudfront-tweaks

/**
* This filter allows you to adjust the path of a CDN (such as CloudFront) URL.
* Useful when using a CDN distribution which uses a subdirectory of a bucket as its source.
*
* @handles `as3cf_cloudfront_path_parts`
*
* @param array $path_parts
* @param string $domain
*
* @return array
*
* Note: Filter uses ‘cloudfront’ in name for historical reasons, can be used with any CDN that
* supports the ability to use a path prefix with bucket as source.
*/
function cloudfront_path_parts( $path_parts = array(), $domain = ” ) {
// Example would allow a CDN distribution of cdn.example.com/media/ to serve files as cdn.example.com.
// Its important to remember that the CDN distribution must have been set up accordingly.
if ( ‘cdn.example.com’ === $domain && 1 < count( $path_parts ) && ‘media’ === $path_parts[0] ) {
unset( $path_parts[0] );
}

return $path_parts;
}


 

*** End of Content ***

Last Update: 02/06/2020