Register an embed handler for self hosted images

Background of my Problem:
I have several hundred images with urls stored in a Toolset Types custom wordpress embedded field, along with video urls. I can display my videos no problem from the embedded field but the images only show the URL not the image.

Solution approach:
I’m trying to write a function to register an embed handler for self hosted images: where the URL refers to my own site, and the function will spit out the markup I need, in this case an image tag.

Here is a sample URL for one of my images:

I’ve looked here

but I don’t see an example for images plus I don’t understand regex. I was hoping someone could help me modify a function like this below from to fit my self hosted image scenario:


wp_embed_register_handler( ‘forbes’, ‘#http://(?:www|video)|embedvideo/)?show=([d]+)&format=frame&height=([d]+)&width=([d]+)&video=(.+?)($|&)#i’, ‘wp_embed_handler_forbes’ );

function wp_embed_handler_forbes( $matches, $attr, $url, $rawattr ) {

$embed = sprintf(
‘<iframe src=”$s&format=frame&height=%2$s&width=%3$s&video=%4$s&mode=render” width=”%3$spx” height=”%2$spx” frameborder=”0″ scrolling=”no” marginwidth=”0″ marginheight=”0″></iframe>’,

return apply_filters( ’embed_forbes’, $embed, $matches, $attr, $url, $rawattr );


many thanks

Read more here:: Register an embed handler for self hosted images

Leave a Reply

Your email address will not be published. Required fields are marked *