Jump to content

PlaceholderImage


Soma
 Share

Recommended Posts

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/

  • Like 17
Link to comment
Share on other sites

  • 5 years later...
  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...