I’m using Craft to add CMS functionality to an e-commerce website via craft/app/bootstrap.php

Trying to pull a 'timeline' structure with a featuredImage Asset Field.

This code works and pulls the full size image, but I can’t work out how to pull the ‘small’ size of image which is set up as a transform.

I assume it should be something like $entry->featuredImage[0]->url['small'] but nothing seems to be working.

Any help appreciated.

$timeline = Craft\craft()->elements->getCriteria(Craft\ElementType::Entry);
$timeline->section = 'timeline';
$timeline->with = 'featuredImage';
$timeline->withTransforms = 'small';

foreach ($timeline as $entry)
          <div class="imgholder"><img src="<?php echo $entry->featuredImage[0]->url; ?>" alt="<?php echo $entry->featuredImage[0]->title; ?>"/></div>
          <h4><?php echo $entry->title; ?></h4>
          <?php echo $entry->body; ?>
  • 1
    Completely untested so adding as a comment, but try: echo $entry->featuredImage[0]->getUrl('small');
    – Brad Bell
    May 12 '16 at 1:21

$entry->featuredImage[0]->getUrl('small'); works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.