##JS Simple Image Expand
A simple Javascript plugin that shows an image in full size on click, and should be compatible up to IE6.
####Basic usage:
In the <head>
tag, include:
<script type="text/javascript" src="your/path/to/simple-image-zoom.min.js"></script>
Before the closing </body>
tag, include:
<script type="text/javascript"> simpleImageExpand(); </script>
By default, the plugin will add functionality to all images with the class expand-enabled
(but you can change this in options).
####Options: You can also specify some options:
zoomClass
- the class of images to add zoom functionality to.zoomMaxWidth
- The max-width of an image when zoomed.zoomMaxHeight
- The max-height of an image when zoomed.overlayOpacity
- Opacity of the overlay (between 0-1).overlayColor
- Any HTML color (HEX, RGB, colorname)iconImg
- A link / dataURI to an icon image as 'Expand' iconiconShow
- Whether to add an 'Expand' icon over the image (TRUE or FALSE)iconSize
- (Square) Size of the icon (eg. '25px', '1em', '10%')iconToggleOnly
- Whether to toggle image expand only on icon click (TRUE), or on the entire picture (FALSE)iconPos
- Any of the CSSposition
properties, in an object, eg:{right: 0, bottom: 0}
dynamicLoad
- Set this to TRUE if lazyloading images/ loading images with AJAX / on the flydynamicInterval
- Rate at which plugin checks for new images to add functionality to. Default is 200ms.
Below are the default settings (so doing simpleImageExpand()
is exactly the same as doing it with the options below):
<script type="text/javascript">
simpleImageExpand({
zoomClass: 'expand-enabled',
zoomMaxWidth: 'initial',
zoomMaxHeight: 'initial',
overlayColor: 'black',
overlayOpacity: '.8',
iconShow: true,
iconSize: '24px',
iconImg: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAqVJREFUeNq8VjuLGlEUnhlHNz5BsnkYXdwQNWCxVoFUWlhJCotgI4LiP5AUlpZiEfwBgljZSBohpaCpUgUkIEELH1EkJCH4fo1jzpE7wZjRnXElB84uc+d6vjnnfOe7l95sNjRFUfeJX1DntQX4T3QWAUaj0XU0GnU3Go2Xk8nESNP0nRE0Gs0vu93+MZvNftDr9RQNGT0PBAKvqtXqa3jPwjN3DiCMBc65XK53hULhPYPlwkzIiyWA8PD/HL7EmCT2BQJR0+nUiOjU+Y0jsbdZ/GNQPobjOCXP88zuOsMwPDinUCjWp9QRA1O7fUGQZrP5Yn/zcDhc+/3+z71ebywVAGNvPxL/7Dd/PxO0wWDAx2Kxr+12ey4nEyE2I/UHUC6q3+8jWTanNEsykE6nY4LB4APIVkmG/O5AQrrQC65SqUyF9VAoZEylUk8BTHEykNA0ArRutVqLZDLZDYfDXyKRSEt4V6vVZrhdLhAqw43D4XiLqkEGbUtvtVqtBDlaA53XYKzX6720WCyqXC7Xh379UQ8y4McSmdbr9TfsgdLx8/l8gQTYzgDLrsrl8jeBFAgMWZq63e6yVCr9QGAsp1arVcxms5UYOCODpjw6EgHK+SSRSFxlMplnbrf70Wq1Uvt8vsfFYvEGZpA9OLBiQ3sM0+l0qoUHKOU1EOahzWZTmc1mFGXFUSCpio09i8fjzeVyySALcc3j8WjESLX78Yxs9sDAAtgqn89/H4/HvBRVOAmIfCltMplUQAp5oirXrFbrvXQ6fWUwGBiR0vKS1fs263Q6Mzg5P4kdIzgKYurNyiHCjsCupZ5Jf5EBLxKnlvG21pDYW6AF3lbIUa4ia1tHKdp9FvMjezAWR2IvUOsud69bwhkvtXeH9uxdt1r0/7pA/hZgACO4VuIsr37kAAAAAElFTkSuQmC',
iconPos: {right: 0, bottom: 0 },
iconToggleOnly: false,
dynamicLoading: false,
dynamicInterval: 200
});
</script>
####Styling You can further style the expand-overlay, icon and image by using the following CSS rules:
#expand-overlay { ... } /* style the background overlay shown when an image is clicked */
#expand-overlay img { ... } /* style the image shown full-size */
.expand-container { ... } /* container in which images are placed after plugin initiation */
.expand-container .expand-icon { ... } /* expand-icon */
Hello from Austin, TX USA. Great stuff. My tech writing students have asked about this. Best I've found! Thanks, Kevin.
David McMurrey, Ph.D.
Business, Government & Technical Communications
Austin Community College
https://mcmassociates.io/dmz_index.html