We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Third-party

Choose the thumbnail image size from YouTube field type

Hi Drew,

Is there a way to pick which thumbnail is output with the YouTube fieldtype? Currently the docs don't mention this and the result is the default thumbnail which is only 120px. From enabling the debug I can see the array contains the different options;

{ "kind": "youtube#videoListResponse", "etag": "\"g7k5f8kvn67Bsl8L-Bum53neIr4/NTmdeXp_mVfcXa_YpRxxmtUqML8\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 1 }, "items": [ { "kind": "youtube#video", "etag": "\"g7k5f8kvn67Bsl8L-Bum53neIr4/tj_r7YPh41kCNvVJMylkno78pVA\"", "id": "fpIFDDbOnoU", "snippet": { "publishedAt": "2017-11-29T10:53:12.000Z", "channelId": "UCPS6P-KSyUHoIoneoh2swNg", "title": "Measuring an Open Grommet", "description": "Grommets Ltd guide on how to measure an Open Grommet. Contact us on +44 (0) 1273 494400 or email sales@grommets.co.uk for any product enquiries #whateveryourgapwecanfillit", "thumbnails": { "default": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/hqdefault.jpg", "width": 480, "height": 360 }, "standard": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/sddefault.jpg", "width": 640, "height": 480 }, "maxres": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/maxresdefault.jpg", "width": 1280, "height": 720 } }, "channelTitle": "Grommets Ltd. UK Rubber Moulding Manufacturers", "categoryId": "22", "liveBroadcastContent": "none", "localized": { "title": "Measuring an Open Grommet", "description": "Grommets Ltd guide on how to measure an Open Grommet. Contact us on +44 (0) 1273 494400 or email sales@grommets.co.uk for any product enquiries #whateveryourgapwecanfillit" } }, "contentDetails": { "duration": "PT2M2S", "dimension": "2d", "definition": "hd", "caption": "false", "licensedContent": false, "projection": "rectangular" }, "statistics": { "viewCount": "79", "likeCount": "4", "dislikeCount": "0", "favoriteCount": "0", "commentCount": "0" }, "player": { "embedHtml": "\u003ciframe width=\"480\" height=\"270\" src=\"//www.youtube.com/embed/fpIFDDbOnoU\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen\u003e\u003c/iframe\u003e" } } ] }
"thumbnails": { "default": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/default.jpg", "width": 120, "height": 90 }, "medium": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/mqdefault.jpg", "width": 320, "height": 180 }, "high": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/hqdefault.jpg", "width": 480, "height": 360 }, "standard": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/sddefault.jpg", "width": 640, "height": 480 }, "maxres": { "url": "https://i.ytimg.com/vi/fpIFDDbOnoU/maxresdefault.jpg", "width": 1280, "height": 720 } }

Thanks,

Terry Upton

Terry Upton 0 points

  • 3 years ago

For now I have circumvented this by using a replace filter.

<perch:content id="video" type="youtube" output="thumb" replace="default|maxresdefault" />

But it seems a it of a hack?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think we usually take the largest, or try. Might be simpler to rewrite the plugin to suit your purpose than try to hack it in the template.