You can change the content width globally using PHP code but what if you only want to change it on one post or page?
You can also change the width and height for a Youtube embed manually using shortcodes.
What if you only want to change it on all embeds using a specific template or on all galleries assigned to a specific category?
Here’s several tested and working code snippets you can easily modify to your own needs.
Place the code at the end of your child themes functions.php file and change the conditional tag if needed.
The above code will change the width for all embeds including videos and galleries for one specific page.
The above code will change the width for all embeds including videos and galleries for one specific post.
The above code will change the width for all embeds including videos and galleries on multiple posts.
The above code will change the content width for all embeds on multiple posts and pages.
The above code will change the content width for embeds on pages using a specific template.
Here’s the difference between using the default content width and a custom content width for your tiled gallery. You can clearly see the custom width enables you to display your media full width as opposed to leaving a gap on the side.
Image Gallery Using Full Content Width
Image Gallery Using Partial Content Width
I hope that’s helps point you in the right direction for changing the content width for media embeds.
- Change Tiled Gallery Content Width For Jetpacks Tiled Galleries
- Show Different Size Youtube Videos on Different Pages