Objective ways to print images in 5.7
This is a community-contributed tutorial. This tutorial is over a year old and may not apply to your version of Concrete CMS.
May 20, 2015
First, get page's image attribute value like:
$img = $page->getAttribute('example_image_attribute_handle');
if ($img) {
// do something
}
Case 1: Print responsive image (if your theme supports responsive image)
$tag = Core::make('html/image', array($img))->getTag();
echo $tag;
Case 2: Add some attributes to the image
$tag = Core::make('html/image', array($img))->getTag();
$tag->alt('alt test');
$tag->title('title test');
$tag->addClass('example class');
echo $tag;
Case 3: Remove some attributes from the image
$tag = Core::make('html/image', array($img))->getTag();
$tag->width = null;
$tag->height = null;
echo $tag;
Case 4: Do not use responsive image (picture element)
$tag = Core::make('html/image', array($img, false))->getTag();
echo $tag;
Case 5: Get thumbnail src of the image
$src = $img->getThumbnailURL('small');
echo \HtmlObject\Image::create($src)->alt('small size image');
Note: Loader::helper('image')
is officially deprecated.