Keyword

Fallback image

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
1 month 5 days ago #173495 by Patrick Valmont
Patrick Valmont created the topic: Fallback image
Hello all,

I am sure this topic has been discussed a thousand times, but I am not sure this works for me.
I follow this guide
www.joomlaworks.net/forum/k2-en/34251-default-image-for-k2-items
and this one
www.joomlaworks.net/forum/k2-en/41394-default-image-for-k2-item

but none works for me.

Same objective, is to have a fallback image which is used by the function attached (item image).
Thank you all!
Attachments:

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

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
1 month 5 days ago #173502 by Fotis
Fotis replied the topic: Fallback image
This requires you to create K2 template overrides so you can provide a fallback image when one is not used. This basically requires to override the sub-templates in both the component and modules (if you use them).

The code example referenced here is correct: www.joomlaworks.net/forum/k2-en/41394-default-image-for-k2-item#143886

You just need to adapt it to any changes that occurred up to v2.9.0 of K2.

The basic point is that you check if $item->image or $this->item->image (depending on context) is empty and if so, you simply output your own image tag.

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.

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
1 month 1 day ago #173556 by Patrick Valmont
Patrick Valmont replied the topic: Fallback image
Hello Fotis, I did create an override being > Com_k2 > templates > default > category_item.php.
Doesn't work. I even edited the file directly in k2. See attached code replaced. Probably something I did wrong. Not sure. Kindly advise.
Attachments:

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

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
1 month 1 day ago #173557 by Patrick Valmont
Patrick Valmont replied the topic: Fallback image
Hello Fotis,

I got it to work. I noticed I used the code twice. It works now but with a problem. It overwrites my k2 items that has images. I thought this trick was only on blank k2 items. The aim is to show an image on k2 items that does not have item-image. Thanks to advise.

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

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
1 month 1 day ago #173558 by Fotis
Fotis replied the topic: Fallback image
Paste back the code block with the image output so I can suggest changes.

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.

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
1 month 9 hours ago #173561 by Patrick Valmont
Patrick Valmont replied the topic: Fallback image
See below<br/>
<div class="catItemImageBlock">
<span class="catItemImage">
<a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">

<?php if(!empty($this->item->image)): ?>

<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;" />

<?php else: ?>

<img src=" placehold.it/700x350 " 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;" />

<?php endif; ?>

</a>
</span>
</div>
<?php endif; ?>

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

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
1 month 2 hours ago #173564 by Fotis
Fotis replied the topic: Fallback image
The code seems correct. Are you sure there's nothing else that could be causing the issues? No other additions or checks elsewhere in the same file?

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.

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
4 weeks 1 day ago #173573 by Patrick Valmont
Patrick Valmont replied the topic: Fallback image
Not that I know of. Now It does not work !! will it be possible to send a Category_item.php file so I can check ?

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

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
4 weeks 1 day ago #173574 by Patrick Valmont
Patrick Valmont replied the topic: Fallback image
Forgot to highlight again, when the code works, it overwrites the item that has images. In reality, it should work on K2 items that are blank. Not the case on my side :(

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

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
4 weeks 1 day ago #173575 by Fotis
Fotis replied the topic: Fallback image
Sure, attach your copy of category_item.php so I can have a look.

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