Keyword

how to change alt tag from k2 image?

More
7 years 2 months ago #164068 by Goran Nešić
Replied by Goran Nešić on topic how to change alt tag from k2 image?
Can you tell me where is this code located exactly and to that to change it. Because I have similar problem, on hover over image I get name of the cached image for example fksdghsagi4685461961.png instead of title.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #164098 by Krikor Boghossian
Replied by Krikor Boghossian on topic how to change alt tag from k2 image?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

More
7 years 2 months ago #164109 by Goran Nešić
Replied by Goran Nešić on topic how to change alt tag from k2 image?

Krikor wrote: The (default) code should look like this:
github.com/getk2/k2/blob/master/components/com_k2/templates/default/item.php#L203

Remember to use overrides:
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates


Hello Krikor I have changed the code but still it is displaying image real name on hover with mouse instead or article name. I am making mistake somewhere.
Here is override I have created for this in my template:
<?php if($this->item->params->get('itemImage') && !empty($this->item->image)): ?>
	<!-- Item Image -->
		<div class="itemImageBlock">
			<span class="itemImage">
				<img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->title)) echo K2HelperUtilities::cleanHtml($this->item->title); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
			</span>

			<?php if($this->item->params->get('itemImageMainCaption') && !empty($this->item->title)): ?>
			<!-- Image caption -->
			<span class="itemImageCaption"><?php echo $this->item->title; ?></span>
			<?php endif; ?>

			<?php if($this->item->params->get('itemImageMainCredits') && !empty($this->item->image_credits)): ?>
			<!-- Image credits -->
			<span class="itemImageCredits"><?php echo $this->item->image_credits; ?></span>
			<?php endif; ?>

			<div class="clr"></div>
		</div>
	<?php endif; ?>
Where am I making mistake?

Thank you again!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #164136 by Krikor Boghossian
Replied by Krikor Boghossian on topic how to change alt tag from k2 image?
This is not the alt tag, this is the title tag.
Replace the contents of the title tags on the <img> element with the ones of the alt tag.

eg:
... title="<?php if(!empty($this->item->title)) echo K2HelperUtilities::cleanHtml($this->item->title); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" />

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