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
How to use Composer with Marketplace extensions
Aug 22, 2024

Composer can be used to manage third-party extensions from the marketplace

Controlling Google Tag Manager Tags Based on Concrete CMS Edit Toolbar Visibility
Aug 13, 2024

This document provides a step-by-step guide on how to control the firing of Google Tag Manager (GTM) tags based on the visibility of the Concrete CMS edit toolbar. It explains how to create a custom JavaScript variable in GTM to detect whether the edit toolbar is present on a page and how to set up a trigger that ensures GTM tags only fire when the toolbar is not visible. This setup is particularly useful for developers and marketers who want to ensure that tracking and analytics tags are not activated during content editing sessions, thereby preserving the accuracy of data collected.

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

Improvements?

Let us know by posting here.