Developer forum

Forum » Swift » Swift Product Details Image - Thumbnails for videos not rendering

Swift Product Details Image - Thumbnails for videos not rendering

Pedro Meias
Pedro Meias
Reply

Hi

DW 9.16.4, Swift v1.24.0

We have a product on witch we added a youtube video as follows

When visiting the product details page - this is how it looks like

 

When checking the HTML it seems the thumbnail image has the url of the video

When checking the template Templates/Designs/Swift/Paragraph/Swift_ProductDetailsImage.cshtml

Lines 433-435 

433:string imagePath = Dynamicweb.Context.Current.Server.UrlEncode(assetValue);
434:imagePath = assetValue.IndexOf("youtu.be", StringComparison.OrdinalIgnoreCase) >= 0 || assetValue.IndexOf("youtube", StringComparison.OrdinalIgnoreCase) >= 0 ? "https://img.youtube.com/vi/" + assetValue.Substring(assetValue.LastIndexOf('/') + 1) + "/mqdefault.jpg" : imagePath;
435:string imagePathThumb = assetValue.StartsWith("/Files/", StringComparison.OrdinalIgnoreCase) ? imagePath.IndexOf("youtube", StringComparison.OrdinalIgnoreCase) < 0 && imagePath.IndexOf(".mp4", StringComparison.OrdinalIgnoreCase) < 0 ? $"/Admin/Public/GetImage.ashx?image={imagePath}&width=180&format=webp" : imagePath : assetValue;

Values for this specific product after line 435

assetValue https://www.youtube.com/watch?v=JxS5E-kZc2s

imagePath https://img.youtube.com/vi/watch?v=JxS5E-kZc2s/mqdefault.jpg

imagePathThumb https://www.youtube.com/watch?v=JxS5E-kZc2s

It seems line 435 is placing assetValue instead of imagePath on variable imagePathThumb

Also, the right path to get the image should be https://img.youtube.com/vi/JxS5E-kZc2s/mqdefault.jpg

Thank you.


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Pedro,

 

That seems to have been fixed just last week. Can you check if updating the file with these changes fixes that particular issue? (It should from what I can tell)

https://github.com/dynamicweb/Swift/blob/main/Swift/Files/Templates/Designs/Swift/Paragraph/Swift_ProductDetailsImage.cshtml

 

Nuno Aguiar

 
Pedro Meias
Pedro Meias
Reply

Hi Nuno,

After updating the file it seems the issues on lines 433-435 reported before were partialy fixed. HTML is pointing to ImagePath instead of assetValue.

But the url itself to get the image if not right yet, it should be https://img.youtube.com/vi/BQREkUgjhhc/maxresdefault.jpg in this case

 

You must be logged in to post in the forum