- Posts: 157
COMMUNITY FORUM
Intro Text as Alt Tag in item view
- Goble002
- Topic Author
- Offline
- Premium Member
Less
More
3 years 6 months ago #178799
by Goble002
Intro Text as Alt Tag in item view was created by Goble002
Hello,
My front-end users would generally create items as follows :
Title : Sunset
Intro Text : Beautiful sunset on the beach with waves
Image caption : "They will skip this field"
I wanted to find a way to use Introtext as alt tag for images. The original code:So I changed :to:
Was thinking that the cleanHtml script would strip the tags <p> so that Intro text :becomes
"Beautiful sunset on the beach with waves" for alt.
thanks for clarifying.
My front-end users would generally create items as follows :
Title : Sunset
Intro Text : Beautiful sunset on the beach with waves
Image caption : "They will skip this field"
I wanted to find a way to use Introtext as alt tag for images. The original code:
<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
K2HelperUtilities::cleanHtml($this->item->title)
K2HelperUtilities::cleanHtml($this->item->introtext)
Was thinking that the cleanHtml script would strip the tags <p> so that Intro text :
"<p>Beautiful sunset on the beach with waves</p>"
"Beautiful sunset on the beach with waves" for alt.
thanks for clarifying.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
3 years 6 months ago #178811
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Intro Text as Alt Tag in item view
That function will convert certain characters to their HTML entity equivalents. To strip any tags change K2HelperUtilities::cleanHtml($this->item->introtext) to K2HelperUtilities::cleanHtml(strip_tags($this->item->introtext)).
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Goble002
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 157
3 years 6 months ago #178823
by Goble002
Replied by Goble002 on topic Intro Text as Alt Tag in item view
This is perfect !
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
3 years 6 months ago #178831
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic Intro Text as Alt Tag in item view
Yeap :)
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.