Keyword

Fallback image

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
5 years 2 weeks ago #173495 by Patrick Valmont
Fallback image was created by Patrick Valmont
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.

More
5 years 2 weeks ago #173502 by JoomlaWorks
Replied by JoomlaWorks on 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.

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

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

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
5 years 2 weeks ago #173556 by Patrick Valmont
Replied by Patrick Valmont on 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
5 years 2 weeks ago #173557 by Patrick Valmont
Replied by Patrick Valmont on 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.

More
5 years 2 weeks ago #173558 by JoomlaWorks
Replied by JoomlaWorks on topic Fallback image
Paste back the code block with the image output so I can suggest changes.

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

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

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
5 years 2 weeks ago #173561 by Patrick Valmont
Replied by Patrick Valmont on 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="item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:item->imageWidth; ?>px; height:auto;" />

<?php endif; ?>

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

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

More
5 years 2 weeks ago #173564 by JoomlaWorks
Replied by JoomlaWorks on 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?

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

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

  • Patrick Valmont
  • Patrick Valmont's Avatar Topic Author
  • Offline
  • New Member
More
5 years 2 weeks ago #173573 by Patrick Valmont
Replied by Patrick Valmont on 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
5 years 2 weeks ago #173574 by Patrick Valmont
Replied by Patrick Valmont on 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.

More
5 years 2 weeks ago #173575 by JoomlaWorks
Replied by JoomlaWorks on topic Fallback image
Sure, attach your copy of category_item.php so I can have a look.

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