Skip to content

Commit

Permalink
Merge pull request #841 from humanmade/urlencode-filename-cdn-purge
Browse files Browse the repository at this point in the history
URL encode filenames in CDN Media Purge
  • Loading branch information
joehoyle authored Feb 8, 2024
2 parents 7f76fcf + bc0a7dd commit 9feb168
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion inc/cloudfront_media_purge/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function purge_media_file_cache( int $media_id ) {
$upload_path = wp_parse_url( $upload_url, PHP_URL_PATH );
$upload_path_info = pathinfo( $upload_path );
$items = [];
$items[] = $upload_path_info['dirname'] . '/' . $upload_path_info['filename'] . '*';
// Make sure the image filename is URL encoded, else CloudFront will not be able to purge it.
$items[] = $upload_path_info['dirname'] . '/' . urlencode( $upload_path_info['filename'] ) . '*';
if ( function_exists( 'tachyon_url' ) ) {
$tachyon_url = tachyon_url( $upload_url );
$tachyon_path = wp_parse_url( $tachyon_url, PHP_URL_PATH );
Expand Down

0 comments on commit 9feb168

Please sign in to comment.