Keyword

Intro Text as Alt Tag in item view

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
2 weeks 6 hours 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.

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
1 week 6 days ago #178811 by Fotis
Replied by Fotis 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)).

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
1 week 6 days 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.

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
1 week 4 days ago #178831 by Fotis
Replied by Fotis on topic Intro Text as Alt Tag in item view
Yeap :)

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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


Powered by Kunena Forum