Custom Page List | Page List Template | Custom Alt tag

Permalink
Hello,

I've created a custom template for the Page List. I could use a hand with some additional PHP. I need to alter this code so I can have custom alt tags within an image when displaying a thumbnail with a Page List block. Currently C5 fills the alt tag with the the name of the file.

Currently the thumbnail is created using:

<?php if (is_object($thumbnail)): ?>
            <div class="ccm-block-page-list-page-entry-thumbnail">
                <?php
                $img = Core::make('html/image', array($thumbnail));
                $tag = $img->getTag();
                $tag->addClass('img-responsive');
                print $tag;
                ?>
            </div>


I need to replace this with something like:

<?php if (is_object($thumbnail)): ?>
            <div class="ccm-block-page-list-page-entry-thumbnail">
            <img src="<?php echo (something here to pull in the thumbnail) ?>" width="<?php echo $img_width ?>" height="<?php echo $img_height ?>" alt=" (something here to display either the image Title or Description)" />
           </div>


Or is there a simple code I can use to override the alt tag?
$alt = (image title or image description);

haundavid
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi haundavid,

I believe by default, an image's title property will be its filename (this can be changed).

Set the alt attribute using the image's title property.
$tag->alt($thumbnail->getTitle());

Set the alt attribute using the image's description property.
$tag->alt($thumbnail->getDescription());
haundavid replied on at Permalink Reply
haundavid
Thank you MrKDilkington! Works wonderful!
<?php
$img = Core::make('html/image', array($thumbnail));
$tag = $img->getTag();
 $tag->addClass('img-responsive');
$tag->alt($thumbnail->getTitle());
/* $tag->alt($thumbnail->getDescription()); */ /* add or switch for description */
print $tag;
 ?>