Skip to content

Instantly share code, notes, and snippets.

@nicohvi
Created August 25, 2016 08:06
Show Gist options
  • Save nicohvi/6d17ef8838bdb7f1aa97ee0d378e3d50 to your computer and use it in GitHub Desktop.
Save nicohvi/6d17ef8838bdb7f1aa97ee0d378e3d50 to your computer and use it in GitHub Desktop.
function removeStyle (img) {
img.removeAttr("width height");
return img;
}
function align (img) {
const side = img.hasClass('left') ? 'left' : 'right';
const parent = img.parent('p:first');
const imageText = parent.next();
parent.addClass(`text-image-container align-${side}`).append(imageText);
return img;
}
export default function init() {
const images = [].slice.call($('.body-text img')).map(wrap);
images
.map(removeStyle)
.map(align)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment