How do I wrap my Youtube video from a Redactor field with Bootstrap's responsive classes? In my Redactor field, I'd like to programmatically wrap all Youtube videos that have been added through Redactor's video plugin with Bootstrap's responsive embed classes. This answers how to add a single class, but Bootstrap requires multiple classes to be added to the wrapper.
In order to add multiple classes to a video added through Redactor, I'm using the Retcon plugin. This is my solution:

{{ entry.body | retconWrap('iframe', 'div.embed-responsive') | retconAttr( 'div.embed-responsive', { 'class' : 'embed-responsive-16by9' }, false ) }}


There are two Retcon filters applied here. The first filter retconWrap wraps matching selectors in whatever you want. In this case, I'm looking for an iframe and wrapping it in 'div.embed-reponsive':

retconWrap('iframe', 'div.embed-responsive')


The second filter, retconAttr, looks for 'div.embed-responsive' (the wrapper you just applied) and applies any additional classes. The "false" indicates that you do not want to destroy any existing classes, just concatenate them:

retconAttr( 'div.embed-responsive', { 'class' : 'embed-responsive-16by9' }, false )


This may not be the most elegant solution, but it works. Frankly, I feel like we should be able to pass multiple classes through the retconWrap filter, but I've tried and it doesn't work.