Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created February 2, 2015 01:37
Show Gist options
  • Save hellofromtonya/1618f7a0454a3b55b8ce to your computer and use it in GitHub Desktop.
Save hellofromtonya/1618f7a0454a3b55b8ce to your computer and use it in GitHub Desktop.
Replace out HEX characters in WordPress attachment URL
add_filter( 'wp_get_attachment_url', 'lunarwp_modify_attachment_url', 10, 2 );
/**
* Replace out hex characters in an URL
*
* @since 1.0.0
*
* @param string $url Attachment URL
* @param integer $post_ID Optional. Attachment ID. Default 0.
* @return string Returns the amended attachment url
*/
function lunarwp_modify_attachment_url( $url, $post_ID )
{
//* the 1st parameter is for the hex to be replaced
//* the 2nd parameter is what to replace it with when found
//* The 3rd parameter is the string to evaluated
$url = str_replace( '%2B', '+', $url );
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment