I've got a channel where the editor is specifying a YouTube link. I'll also need a still from the video, which I can get from YT (see https://stackoverflow.com/questions/2068344/how-to-get-thumbnail-of-youtube-video-link-using-youtube-api); but I want to store the image locally. How would I go about capturing or uploading the file to my upload directory, and having EE perform the resizing service?

Thanks for your help.

Update: I should have specified that I don't want the user to upload the video still. At this point I've got the video ID, and the CMS should fetch the still from YT, and load it into EE's file manager. Any way to do that?

  • Are you open to using a plugin for image processing and local caching (ie, do it all in your templates), or do you definitely want these housed in EE upload directories and for EE to do the processing?
    – Alex Kendrick
    Commented Apr 10, 2013 at 2:36
  • @AlexKendrick Definitely want to use EE's resources for hosting and resizing the images. It makes sense to do so, otherwise you're putting more "business logic" (the resize info) somewhere else, making it harder to maintain. Commented Apr 10, 2013 at 15:24
  • 1
    Gotcha. Well, I'd still recommend taking a look CE Image which would cache local, sized versions of the remote images for you. I've not found this approach to introduce any maintenance headaches.
    – Alex Kendrick
    Commented Apr 10, 2013 at 15:48
  • @AlexKendrick Thanks. I'd make that an answer. Maybe with a link to the add-on. Commented Apr 10, 2013 at 16:05

2 Answers 2


If you are not completely married to the idea of storing and syncing the remote images with an actual EE upload directory, and using EE for all image size processing, then take a look at CE Image.

CE Image can work with remote images, resizing them as needed (very customizable) and then storing a cached local copy on your server. It is a very well-documented and flexible add-on with a ton of features. It's my go-to for all image manipulation and judging by all the rave reviews it has I don't think I'm alone on that!


First of all you need to download the YouTube image via CURL and after that save it within the preferred directory.

$imgURL = 'youtube image link';

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $imgURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$imgContents = curl_exec($ch);

$upload_dir_path = 'upload/directory/path';

$file = @fopen($upload_dir_path, 'wb');
@fwrite($file, $content);

Please Note: I didn't test above code. It would give a good pointer to code this feature.

  • Good start. I imagine this would need to go in a custom field type? How does EE know that the image you just wrote to the directory needs to be resized and written to the DB? Commented Apr 10, 2013 at 15:26
  • As you can see within the code, I am using the PHP's file function for saving the images directly into a directory. Yes, it can be a custom field type. But I think, there would be already such a third party field type but not sure about it. To get it with EE, you need to do some more coding stuffs using the File class of EE. By which you can re-size the image and can save to desired Upload Directory. Also, you can maintain the file manager for the downloaded remote image. Commented Apr 10, 2013 at 15:44
  • I'd just want to hand it off to EE in some way, and let it do the resizing and maintaining of the file manager. Otherwise, once again, we're coding the same thing twice, and it becomes less maintainable. Commented Apr 10, 2013 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.