Max image width setting cropping Youtube previews

Lately on our forum, all the embedded Youtube videos show with only half of the image preview within the video box, like so:

This seems to be related to the max image width setting (which we have set to 340px), as the behavior goes away when we remove that value. I didn’t expect this setting to impact videos though… Is this a bug, perhaps?

4 Likes

FWIW, I think the max image width shouldn’t apply for video (even if technically the preview is done with an image thumbnail). As is it it makes videos look a little broken due to the cropped preview.

As opposed to:

One idea would be to have a separate setting for max video width that applies to videos+thumbnails. Another possibility would be to respect the image max width on the thumbnail, but expand the video object on play. These are only suggestions — I don’t know how complex either of these ideas are to implement.

1 Like

Yes, this site setting indeed affects all images, including the YouTube thumbnails.

Looks like we need to add another exception for youtube on

https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/app/initializers/ensure-max-image-dimensions.js#L25

cc @jordan.vidrine. To repro locally change the setting and refresh the page.

6 Likes

This bug has been addressed and a fix has been merged. Thanks for bringing it to our attention :smile:

8 Likes

This topic was automatically closed after 14 days. New replies are no longer allowed.

This has been fixed on the posts (youtube thumbnail), but it still crops horizontally squeezes the thumbnail preview on the composer when the max image width is low:

2 Likes

Thanks for reporting, are you still seeing this issue?

1 Like

I confirm this is still happening on stable. I’m afraid I don’t have a tests-passed instance at hand where I can check this right now.

This is happening when max_image_width=340.

Once posted, the embedded video itself is fine (ie, image width doesn’t apply to the video) and that part is fixed. But while composing the message, the thumbnail preview gets squeezed. Technically an image, but I don’t think the max_image_width should apply here?

2 Likes

I recently worked on some changes to image sizes in the post stream (and by extension, previews), and I believe this issue is no longer present in tests-passed. I just tested it locally by setting the max_image_width setting to 340 and using a YouTube link in a post, and I cannot reproduce the issue.

So for the stable branch users, the solution is to wait until the next stable release.

3 Likes