How does this theme support responsive video shortcodes?
-
WP 3.6+ has integrated MediaElementJS into the core and I think that’s great. However I’ve been troubleshooting getting videos to be responsive using shortcodes.
I write custom themes from the ground up for clients and I knew something was wrong with theme I was writing because videos are responsive with no problems using Twenty Thrirteen. However when I switch to my theme none of the videos are responsive.
While using shortcodes, I eventually noticed that Twenty Thirteen rendered
style="width: 100%;"on the video element in it’s markup and my theme wasn’t. I was really curious as to why this was happening. Eventually I ended up looking in WP’s core. In /wp-includes/media.php on line 1071 I found:$html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );I modified that line to:
$html .= sprintf( '<video %s controls="controls" style="width: 100%%;">', join( ' ', $attr_strings ) );After manually forcing WP to include 100% width my videos are now responsive. I tried adding 100% with to the shortcode used in my content and it doesn’t work. It was interpreted as 100px in my theme. But somehow it does with Twenty Thirteen.
I understand that modifying the core is a bad idea so I’m curious, how does Twenty Thirteen honor the inline width 100% for responsive videos without hacking the core? I searched for filters and couldn’t find any.
The topic ‘How does this theme support responsive video shortcodes?’ is closed to new replies.
