简体   繁体   中英

Joomla 3.7.1 - Adding Links and title tags to article intro images

Hi guys wondering how I can manually add a link from Joomla intro article images to their corresponding article and also add a title tag to the link.

Ideally the way I want to do this is to for example wrap an achor tag around the image reference in the blog-item.php file (also want to achieve this for generic articles). And then within the anchor tag capture the related image alt tag and populate the title tag with that value.

Below is where I'm at. It's not currently working, not sure why as it should be pretty straight forward. I'm not a php developer, wondering what i'm missing.

Also already cleared both browser and joomla caches after my changes.

Any help would be appreciated, cheers guys

                <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>" title="<?php echo htmlspecialchars($images->image_intro_alt); ?>">
            <img

                src="<?php echo htmlspecialchars($images->image_intro); ?>"
                alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
            </a>

To make your code work, add just before your code.

<?php $images = json_decode($this->item->images); ?>

and your code will start working.

Already tested and it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM