Reputation: 11
We have our images and PDFs in a custom location on the server. The URL to them includes a folder with curly braces in the name, like this: /{folder-name}/. I understand that having a folder with curly braces in the name is not good, but we are stuck with it for now.
When the image is uploaded the final URL shown with the image in the Media tab is correct and includes the curly braces. When I try and embed the image in a post, the curly braces are stripped out, so like this /folder-name/, and the final URL no longer works. When the post is previewed the image is broken.
Screenshots showing the embed process:
Image showing the WP Embed overlay. At this point the image URL is still correct.
Question How do I turn off the image URL sanitizing happening when I embed an image in the post? Is there a function that will force the embed to use the original attached image URL and not the sanitized version?
I tried adding following in functions.php file. None worked:
add_filter( 'sanitize_url', static function( $filtered, $original_string ) { return $original_string; }, 10, 2 );
add_filter( 'sanitize_textarea_field', static function( $filtered, $original_string ) { return $original_string; }, 10, 2 );
I also looked at 'wp_get_attachment_url' but I do not understand how to create a function that will return the original non-modified URL. This does not work.
add_filter('wp_get_attachment_url', 'return_non_modified_url');
function return_non_modified_url($url) {
return $original_string;
}
Thanks for your help.
Upvotes: 1
Views: 53