Last active
December 15, 2015 03:19
-
-
Save meenie/5193291 to your computer and use it in GitHub Desktop.
Munee undocumented feature - Image Placeholders
This file contains hidden or 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
<?php | |
require 'vendor/autoload.php'; | |
/** | |
* A new feature in Munee is being able to use image placeholders for missing images. | |
* This is a great feature to have if you are designer just starting a new site and don't necessarily have | |
* all of your images available. You can specify a specific image or use one of the numerous image placeholder | |
* websites out there like http://placedog.com. | |
* | |
* You can also specify different image paths for different placeholder images as well. | |
* So if you want a different image for all of your /img/category/* images and another for all of your /img/product/* | |
* images, it's very easy to do. | |
*/ | |
// Use a placeholder for all missing images | |
echo \Munee\Dispatcher::run( | |
new \Munee\Request(array( | |
'image' => array( | |
'placeholders' => array( | |
'*' => WEBROOT . DS . 'img' . DS . 'placeholder-image.jpg' | |
) | |
) | |
)) | |
); | |
/** | |
* Use a placeholder for all generic images, a specific placeholder for product images, | |
* and a placeholder service for category images. | |
* /img/category/missing-image.jpg --> Pulls in a random puppy image | |
* /img/product/missing-image.jpg --> Uses /img/missing-product.image.jpg | |
* /img/wherever-else/missing-image.jpg --> Uses /img/placeholder-image.jpg | |
*/ | |
echo \Munee\Dispatcher::run( | |
new \Munee\Request(array( | |
'image' => array( | |
'placeholders' => array( | |
'/category/*' => 'http://placedog.com/1024/768', | |
'/product/*' => WEBROOT . DS . 'img' . DS . 'missing-product-image.jpg', | |
'*' => WEBROOT . DS . 'img' . DS . 'placeholder-image.jpg' | |
) | |
) | |
)) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment