Keyword

Intro Text as Alt Tag in item view

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
2 years 11 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:
<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;" />
So I changed :
K2HelperUtilities::cleanHtml($this->item->title)
to:
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>"
becomes
"Beautiful sunset on the beach with waves" for alt.

thanks for clarifying.

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #178811 by JoomlaWorks
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
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
2 years 11 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.

More
2 years 10 months ago #178831 by JoomlaWorks
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.


Powered by Kunena Forum