spicywebau / craft-embedded-assets

Manage YouTube videos, Instagram photos and more as first class assets in Craft CMS
MIT License
171 stars 35 forks source link

Limit urls by domain (example youtube only) #230

Closed mike-moreau closed 1 year ago

mike-moreau commented 1 year ago

What would you like to see added to or changed in Embedded Assets, and why?

Embedded assets flexibility is super. But there are times I'd like to limit what urls can be embedded: for example, allowing embedded assets of youtube videos only.

What would you think about adding a config option that could limit embeds to only whitelisted domains?

ttempleton commented 1 year ago

It hadn't occurred to me until now, but this can be achieved with a combination of overriding the plugin's whitelist setting, and enabling the plugin's preventNonWhitelistedUploads setting, by setting the following in your Craft project's config/embeddedassets.php file:

<?php

return [
    'preventNonWhitelistedUploads' => true,
    'whitelist' => [
        'youtu.be',
        'youtube.com',
        'youtube-nocookie.com',
    ],
];
mike-moreau commented 1 year ago

Super! Thank you for the reply.