Book Image

concrete5 Beginner's Guide

Book Image

concrete5 Beginner's Guide

Overview of this book

Table of Contents (19 chapters)
concrete5
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – restricting thumbnails to a custom dimension


Sometimes you might have to specify an exact dimension to suit your needs. concrete5 has several helper classes, one called image which offers several functions, including a function which generates and caches a thumbnail.

<?php 
$imageHelper = Loader::helper("image");
for ($i = 0; $i < count($cArray); $i++ ) {
    $cobj = $cArray[$i]; 
    $title = $cobj->getCollectionName(); ?>

<h3 class="ccm-page-list-title"><a href="<?php echo $nh->getLinkToCollection($cobj)?>"><?php echo $title?></a></h3>
<?php 
$thumbnail = $cobj->getAttribute('thumbnail');
if ($thumbnail) {
   $thumbnailObj = $imageHelper->getThumbnail($thumbnail,200,200);
   echo '<div class="ccm-page-list-thumbnail">'; 
   echo "<img src=\"{$thumbnailObj->src}\" alt=\"\" width=\"{$thumbnailObj->width}\" height=\"{$thumbnailObj->height}\"/>";
   echo '</div>';
} ?>
<div class...