Customize WordPress Jetpack Shortcode Widths

wordpress jetpack

When WordPress released the Jetpack plugin, they opened the average WordPress installation up to some great features that they include on their hosted solution. Once you enable the plugin, you enable a ton of features, including shortcodes. By default, WordPress doesn’t allow your average author to add media scripting within the content of a post or page. This is a security feature and meant to minimize the chances of messing up your site.

However, with shortcodes, your user can embed media quite easily. For example, to embed a Youtube video, there’s no need to add embed script – you just put the shared URL to the video in the text editor. The integration of shortcodes identifies the path and replaces the URL with the actual video code. No fuss, no issues!

Except for one. Using shortcodes, the width of your embedded media just defaults. So Youtube may expand beyond the width of your content and spill over on your sidebar – or Slideshare may take up half the space that it could take up. I spent an exhaustive few hours trying to identify how to write some filters to default the widths of each specific shortcut. I reviewed a ton of plugins to see if there was one already out there.

And then I found it… a brilliant little modification that WordPress added to their API. A setting where you can default the width of the content on your pages and posts:

if (!isset( $content_width )) $content_width = 600;

As soon as I set this width in my theme’s functions.php file, all the embedded shortcut media was properly resized. While I’m happy that it only took a line of code, I’m a big frazzled that it took so long to find this. Even more interesting is the lack of customization available with Jetpack. Shortcodes, for instance, can not be disabled – it’s enabled as long as the plugin is enabled.

It would have been brilliant, for example, to add a maximum width and height setting directly on the Jetpack Shortcode settings. WordPress is such an incredible platform, but sometimes finding the solution can be a bit frustrating!

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.