(Onlinerender) #1

Hi nice work on the forums btw***

I am having some issues adding sketchfab to wordpress via oembed , I know you guys have a plugin and if the worse comes to the worse, i'll just catch the shortcode function and attach to a custom field, however I want to give a proper integrated look and feel hence why a native oembed support via the fuctions.php is more beneficial on our part.

i think the issue is url paths / wildcard

any help appreciated & thanks in advance



// Register oEmbed providers
function sketchfab_oembed_provider() {

	wp_oembed_add_provider( '#https?://(www\.)?.sketchfab.com/model*, 'https://www.sketchfab.com/oembed/*', true );


// Hook into the 'init' action
add_action( 'init', 'sketchfab_oembed_provider' );

(Bart) #2

Awesome! I actually started this myself too, but I found I couldn't set the width of the embed to match my theme (which is 728, and higher than the default embed size of 640). How does this work for you?

And yes, I really do prefer this way of embedding in WordPress too smile (Did you know it works the same way here on the forum?)


I'm not very familiar with oembed, can you just do this?

wp_oembed_add_provider( 'https://sketchfab.com/models/*', 'https://sketchfab.com/oembed' );

@bartv - maxwidth and maxheight parameters?


(Onlinerender) #4

cheers for the info ,I went back and done further testing , the intial code actually works fine, I can now embed sketchfab as cover image on my profiles * nice

// Register oEmbed providers
function sketchfab_oembed_provider() {

	wp_oembed_add_provider( 'https://sketchfab.com/models*', 'https://sketchfab.com/oembed' );


// Hook into the 'init' action
add_action( 'init', 'sketchfab_oembed_provider' );

the only issue I am having is , wordpress is lying and displays
No oEmbed Results Found for https://sketchfab.com/models/276403ae0c844698adb10d78c5239bfb. View more info at codex.wordpress.org/Embeds.
but it could be theme related or custom field error*****

however as for the functionality of the code it works fine , as soon as a user enteres a sketchfab url, it embeds properly

note* the above code should be placed in the functions.php of your theme

(Ramiy) #5

@james, sketchfab.com has oEmbed support.

But in WordPress, you need to add a oEmbed provider. WordPress has built in out-of-the-box list of providers https://codex.wordpress.org/Embeds but sketchfab is not one of them. You need to add a provider.

Anyone can add oEmbed providers using tools like: http://generatewp.com/oembed/

For more information about the parameters, read this: http://generatewp.com/introducing-oembed-provider-generator/

(3 Dmaven) #6

If we're on Wordpress.com instead of Wordpress.org, are we just out of luck then? Unless I'm mistaken, Wordpress.com does not allow you to access your site via FTP or upload custom themes (and modifying functions.php would be both).


I'm afraid so. Wordpress.com hosted sites don't allow the iframe tag and don't allow plugins frowning

(Bart) #8

I guess we need to build some contacts with WordPress then eh smile

(Ramiy) #9

I have released an oembed plugin for sketchfab.

You can download the plugin from: https://wordpress.org/plugins/sketchfab-oembed/

OR go to your "WordPress Dashboard" -> "Plugins" -> "Add Plugin" and search for "Sketchfab oEmbed".

(Bart) #10

Hey @ramly,

cool! I just tried your plugin but did fine one issue: the embeds don't honor my media settings sizes, resulting in an embed that's 1000px high. Any ideas what we can do about that?

(Ramiy) #11

This is tricky, i wrote a codex page about this.

Each theme can set a $content_width variable to set the maximum allowed width for any content in the front-end. WordPress uses this variable to set the embed content width.

You need to understand that different themes uses different content widths, this way when you switch themes you don't need to update all your embeded content in all your posts. WordPress does it automatically using the $content_width variable.

I guess your theme don't have this variable. Use this tool (content width tab) to generate a valid code and add the code to your theme function.php file.

(Bart) #12

Actually I think I do. This is in my functions.php:

/* change theme width */
$content_width = 728;

When I look in the HTML, the width is fine, but the height is set to 1000 pixels:

<p><iframe width="728" height="1000" src="https://sketchfab.com/models/49277b24b9e645e3afb27de216d64d15/embed" frameborder="0" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" onmousewheel=""></iframe>

These are my media settings:

(Bart) #13

Hey @ramiy, any ideas?

(Ramiy) #14

Try using this filter to update your theme embed size:

function my_embed_defaults() {
	return array(
		'width'  => 728,
		'height' => 375
add_filter( 'embed_defaults', 'my_embed_defaults' );

(Bart) #15

Yeah that works, thanks! I assume this will also affect the size of other embeds, like YouTube or Vimeo?