You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
There's probably a nicer way to achieve this but I cooked up a new script to add support for image wrappers with an additional class for aspect ratio-support.
It'd be great to see this added in for future use.
// Example UsageconstimageSelectors='.rte img'wrapImage({$images: $(imageSelectors),imageWrapperClass: 'rte__image-wrapper'});// Returns<divclass="rte__image-wrapper rte__image-wrapper--(portrait|landscape|square)"><imgsrc="..."alt=""></div>
/** * Wrap images in a container div with an additional class for its aspect ratio * * @param {object} options - Options to be used * @param {jquery} options.$images - jquery object(s) of the table(s) to wrap * @param {string} options.imageWrapperClass - image wrapper class name */functionwrapImage(options){constimageWrapperClass=typeofoptions.imageWrapperClass==='undefined' ?
'' :
options.imageWrapperClass;options.$images.each(function(){constheight=$(this)[0].clientHeightconstwidth=$(this)[0].clientWidthconstimageAspectRatio=aspectRatio(height,width)$(this).wrap(`<div class="${imageWrapperClass}${imageWrapperClass}--${imageAspectRatio}"></div>`);})}functionaspectRatio(height,width){letaspectRatioValue=(height>width) ? 'portrait' :
(height===width) ? 'square' :
(height<width) ? 'landscape' : null;returnaspectRatioValue;}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
There's probably a nicer way to achieve this but I cooked up a new script to add support for image wrappers with an additional class for aspect ratio-support.
It'd be great to see this added in for future use.
The text was updated successfully, but these errors were encountered: