Keyword

K2 2.8 breaks img srcset - malformed path

  • Jack Hughes
  • Jack Hughes's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 1 month ago - 7 years 1 month ago #164395 by Jack Hughes
K2 2.8 breaks img srcset - malformed path was created by Jack Hughes
I have also posted this to the K2 Github.

I have adapted srcset code share by Krikor to responsively display images in my K2 layout overrides.

This code worked in 2.7.1 - from item.php
<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); ?>" sizes="(min-width:960px) 726px,(min-width:768px)  911px,(min-width:481px)  739px,452px" srcset="<?php echo $this->item->imageXSmall; ?> 200w,<?php echo $this->item->imageSmall; ?> 300w,<?php echo $this->item->imageMedium; ?> 500w,<?php echo $this->item->imageLarge; ?> 800w,<?php echo $this->item->imageXLarge; ?> 1200w" />

In K2 2.8.0 the image does not show. the same code renders out as such...
<img src="/media/k2/items/cache/5734ccbbcc4bd04e97372ff3dad99251_L.jpg" alt="White Pines State Park" sizes="(min-width:960px) 726px,(min-width:768px)  911px,(min-width:481px)  739px,452px" srcset="//media/k2/items/cache/5734ccbbcc4bd04e97372ff3dad99251_XS.jpg 200w,//media/k2/items/cache/5734ccbbcc4bd04e97372ff3dad99251_S.jpg 300w,//media/k2/items/cache/5734ccbbcc4bd04e97372ff3dad99251_M.jpg 500w,//media/k2/items/cache/5734ccbbcc4bd04e97372ff3dad99251_L.jpg 800w,//media/k2/items/cache/5734ccbbcc4bd04e97372ff3dad99251_XL.jpg 1200w" class="">

Notice the leading slashes in the srcset code. If you remove the extra slash the image appears.

So far I can confirm that this happens in item.php and category_item.php. I am assuming the same fate if used in mod_k2_content.

We are having to hold off updating other large K2 run websites due to this issue.
Last edit: 7 years 1 month ago by Jack Hughes.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #164400 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 2.8 breaks img srcset - malformed path
Hello,

Fotis answered your question here -> github.com/getk2/k2/issues/420

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

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

  • Jack Hughes
  • Jack Hughes's Avatar Topic Author
  • Offline
  • Junior Member
More
7 years 1 month ago #164409 by Jack Hughes
Replied by Jack Hughes on topic K2 2.8 breaks img srcset - malformed path
Hey Krikor,

I have sent you an email to your gmail account.

Thanks
Jack

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 1 month ago #164421 by Krikor Boghossian
Replied by Krikor Boghossian on topic K2 2.8 breaks img srcset - malformed path
As stated in the thread it is most likely a core issue and a fix has been proposed.

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