Soma Posted October 29, 2014 Posted October 29, 2014 PlaceholderImage A simple placeholder class to generate base64 data uri string that can be used to create placeholders for prototypes or as placeholders for lazy-loaded images. Original credits for the PHP Class go to Patrick van Marsbergen. https://github.com/marsbergen/PHP-Placeholder Use this module in templates to generate placeholder images. It doesn't create a physical image but a base64 data uri string to use as the src of image tag. You can get the base64 code or the complete img tag for convenience. Example chained call: $base64 = $modules->PlaceholderImage->width(640)->height(480)->background('DDDDDD')->render(); Then insert the string as the src like: <img src="<?php echo $base64?>"> Or pass true to render() to get a complete <img> tag $imgTag = $modules->PlaceholderImage->width(640)->height(480)->render(true); Or static calls for convenience: $base64 = PlaceholderImage::image(150,100); $base64 = PlaceholderImage::image(150, 100, 'FF0000', 'FFFFFF', 'Custom text'); $imgTag = PlaceholderImage::imagetag(150, 100, 'FF0000', 'FFFFFF', 'Custom text'); Github repo https://github.com/somatonic/PlaceholderImage On PW modules http://modules.processwire.com/modules/placeholder-image/ Live Example on lightning.pw http://radium-0rq.lightningpw.com/ 17
Soma Posted October 29, 2014 Author Posted October 29, 2014 Just added demo example using lightning.pw http://radium-0rq.lightningpw.com/ 1
arjen Posted October 29, 2014 Posted October 29, 2014 Nice one soma! Gonna try this as an alternative to placehold.it. 1
OrganizedFellow Posted October 30, 2014 Posted October 30, 2014 https://github.com/imsky/holder That's the one I used to use. 1
elabx Posted April 29, 2020 Posted April 29, 2020 Just came here to say this module works perfect up to date, testing on 3.0.148 ?. Thanks @Soma! 1
OrganizedFellow Posted June 26, 2020 Posted June 26, 2020 On 4/28/2020 at 6:15 PM, elabx said: Just came here to say this module works perfect up to date, testing on 3.0.148 ?. Thanks @Soma! Great news! Adding this to my "next to try" Modules, lol.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now