Created
August 25, 2016 08:06
-
-
Save nicohvi/6d17ef8838bdb7f1aa97ee0d378e3d50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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