No ALT Text on Thumbnails

Permalink
In the file manager properties, I put a title, description, and tag but none of those show up as alt text description on a thumbnail image in pagelist, carousel, etc. All I get when inspecting a thumbnail is alt="#".

Does concrete5 8.4.1 provide a way to set Alt text to make thumbnail images accessible in pagelist block, carousel, etc.?

Please help.

 
mnakalay replied on at Permalink Best Answer Reply
mnakalay
You would need to create a block template to specifically add the proper content to the alt attribute.
For instance, in the page list block, inside view.php, around line 105 you have
<?php if (is_object($thumbnail)) {
    ?>
    <div class="ccm-block-page-list-page-entry-thumbnail">
        <?php
        $img = Core::make('html/image', [$thumbnail]);
        $tag = $img->getTag();
        $tag->addClass('img-responsive');
        echo $tag; ?>
    </div>
    <?php
} ?>

If you create a template where you modify that code this way:
<?php if (is_object($thumbnail)) {
    ?>
    <div class="ccm-block-page-list-page-entry-thumbnail">
        <?php
        $img = Core::make('html/image', [$thumbnail]);
        $tag = $img->getTag();
        $tag->addClass('img-responsive');
        $altText = $thumbnail->getTitle();
        if ($altText) {
            $tag->alt(h($altText));
         } else {
             $tag->alt(t("Some fallback text?"));
        }
        echo $tag; ?>
    </div>

It will use the image's title field for the alt text.
Kurtopsy replied on at Permalink Reply
Kurtopsy
This is very helpful! Thanks!