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.

Recent Tutorials
Upgrading Concrete from 8.5 to 9.x
Jun 21, 2024
By myq.

How to avoid problems upgrading from 8.5 to 9.x

How to change the default date format
May 30, 2024
By myq.

Change the format of the default date

WebOps Tutorial on Running and Upgrading a Concrete CMS Website
May 2, 2024
By myq.

Describes how to deploy, manage, and upgrade a Concrete CMS website

Using the Concrete Migration Tool Addon
Apr 27, 2024

How to use the Concrete CMS Migration Tool

Create custom Site Health tasks
Apr 19, 2024
By myq.

This tutorial will guide you through the creation of a new Site Health task

Reusing the same Express entity in multiple associations
Apr 11, 2024
By myq.

How to create and manage multiple associations in Express

Improvements?

Let us know by posting here.