Jump to content
adrian

Youtube And Vimeo Thumbnail Grabber

Recommended Posts

This is a very simple module that I put together for @Zahari Majini from a PM request.

It allows you to enter a URL to a YouTube or Vimeo video in a specified field and when you save the page, it will grab thumbnails for the video and add them to a specified images field.

Check the module configuration options for:

  • the field(s) to search for videos
  • name of the video images field
  • which thumbnail(s) you want grabbed
  • whether to grab the first available or all available thumbnails based on those that you list

As always, an feedback for improvements is very welcome!

 

Modules Directory: http://modules.processwire.com/modules/process-get-video-thumbs/

Github: https://github.com/adrianbj/GetVideoThumbs

post-985-0-42973500-1381164961_thumb.png

post-985-0-01921900-1381164969_thumb.png

  • Like 13

Share this post


Link to post
Share on other sites

Hey Ryan,

I have come up against that wireEncodeJSON issue with a leading 0 (that I had in the phone field module) again with this module. I guess I will need to implement the same workaround, appending a tilde and stripping on loading again.

Any chance you could make that change to allow for leading zeros so we don't have to do this forever?

Thanks

  • Like 1

Share this post


Link to post
Share on other sites

There's also a highres if the upload is HD and Youtube has processed the video. But you need to check, before using.

My experience is that YouTube doesn't always provide every image. If the image is not available, google gives a smaller image back then expected.

Share this post


Link to post
Share on other sites

Thanks Martijn,

That high res version is great - "maxresdefault". It is the only one that doesn't get letterboxed, which actually makes it useful, unlike the other ones! 

I also added "hqdefault" and "default" as other default options. I also added checks to make sure an image exists before trying to add it to the images field.

Now along with Antti's thumbnail module, Horst's PIM module, or your Image Interceptor module it should be possible to manipulate that high res version however the user wants!

  • Like 1

Share this post


Link to post
Share on other sites

Ok, just added another new option (v5). You can now decide whether you want to grab all the available images listed, or just the first available one (default).

This way you can list all available images, but if one doesn't exist, it will move onto the next in the comma separated list until it finds one that does exist. List them in your order of preference.

Share this post


Link to post
Share on other sites

Wow! Isn't this a truely amazing community!!!

I am so so so grateful to Adrian for having created this!

I'm trying to create a site that will help categorize and show videos from my Vimeo account. The oembed module from Ryan makes it so easy to just copy the url and paste it into our text editor. This was one great great step forward.

The thing that was missing / needed imho was a way of automatically fetching the thumbnails of these videos so that when we create a list of video episodes with a title and description, we could make these excerpts and our page of results way more interesting and media rich by displaying a thumbnail of our video as well!!

I'm one slow learner. Go ahead and laugh... but the first thing I thought of to do all this was create an image field and then looked for a screen capture program that could take a picture of the oembeded video showing on my page at full size, and then manually feeding that screen grab into a custom image field for the page to subsequently display it resized into a thumbnail. So i thought after doing this the manual way, surely the video hosters might give you a way of extracting an image from the video and sure enough, looking at the Vimeo API, they did.

And so I wrote to Adrian asking him if he could help me / point me into the right direction as to how to go about doing this. I initially thought that we needed to modify Ryans oembed module. But Adrian explained to me that way to go about it conceptually was to create a hook before you save the page, get the image from Vimeo or whoever, and use the PW API to save this to an image field.

Ahhh... an Eureka moment for me! Now hooks in PW make more sense to me and of course having the obvious need for this hook, we now know that we need our PW API for saving an image so the API's relevance seems much greater now too!! Somethings abstract instantly become a developers best friends!!

BTW, I used hooks in WordPress quite a bit as basically there were so many things you wanted WP to do differently, and so hooks are typically used there to swap out and change the behaviour of a particular function. But I never really looked at hooks in PW as it seems to do everything right in the first place and as a result never really had any reason to even look into them :biggrin:

Anyways... can't wait to try this module and see how it works!

Thank you Adrian !!!!!!!

  • Like 1

Share this post


Link to post
Share on other sites

v6 now has optional (default) automatic file renaming.

Images will be named with this format: videoID-ImageName.jpg 

where, the videoID is the ID of video from YouTube or Vimeo and ImageName is the name of the image and matches those names that are in the Youtube Image Names and Vimeo Image Names config fields.

I think this standardized format will make it much easier to call the images via the API in templates.

Ok, hopefully that is it for a while unless anyone else has any other suggestions :)

  • Like 1

Share this post


Link to post
Share on other sites

Hey Adrian

I just downloaded version 5 and one minute later I came back here to report how awesome it is and that it works!!!

But now, what do I see? There is now a version 6!

You are truly prolific and awesome!

Just as a note, Video Image Names lists as its placeholder text: thumbnail_large, thumbnail_medium, thumbnail_small.

Perhaps this placeholder list needs to be swapped around as it says below this:

Default: thumbnail_small, thumbnail_medium, thumbnail_large

What I did was I swapped around the placeholder text to match your default description text, that is to say I entered thumbnail_small, thumbnail_medium, thumbnail_large

and then I selected First Image under Which Images.

This works great!!

Your idea of adding the video ID to the thumbnail was brilliant too Adrian!!

AWESOME!!!!!!! :-) :-) :-)

Share this post


Link to post
Share on other sites

v6 takes care of the inconsistent order between default and the labeling. I still have the default order with large first though as I figure you can always resize with the PW API, but obviously it comes down to each use case, which is why the order is configurable :)

I'll add to the modules directory now, so updating to new versions will be easy :)

Thanks for the kudos.

Share this post


Link to post
Share on other sites

Ahah...

What you say makes great sense Adrian about grabbing the bigger / biggest one so that we can subsequently resize it smaller should the need arise.

Thanks again Adrian!

:-)

Share this post


Link to post
Share on other sites

Just pushed a new update that supports multiple videos in multiple fields on a page, so this should now work seamlessly with the VideoEmbed module.

Also, you can now select the fields to search and the images field to populate using dropdown selects, rather than manually entering. The list of fields is limited to appropriate field types.

Thumbnails in first post have been updated to show new functionality.

  • Like 1

Share this post


Link to post
Share on other sites

Adrian, I must admit, I didn't install/test your module yet. But I love it as it works the way you told us.

Within the next 2 or 3 weeks or so I gonna start a bigger project. A thing it need, is to find articles containing a video.

Your module will be installed for that, as I can query for images, thus containing a video.

I thing I wish ( Maybe I can build, or it's already in there ) is that it deletes the images if the url to the video is gone.

I hope I will find time to work on it this week. 

Are you open for additions to this module ?

Share this post


Link to post
Share on other sites

Hey Martijn,

I have made some substantial changes and pushed to github:

  • Images are no longer deleted and repopulated by default - makes saving the page when there are no changes to the videos much faster as this module doesn't have to do much.
     
  • Any images that are from videos that have been removed from the page are now deleted on a per video basis (ie if the URL is now gone)
     
  • I have removed the option to disable image renaming - renaming proved essential to make the above two options work properly. I don't think this should be a problem.
     
  • Renaming is handled slightly differently now
    • if you choose "First Available" for Which Images, it will name the image like so: videoID.jpg (eg: pmqzchx-mtc.jpg)
       
    • if you choose "All Available" images it will append the name to the videoID: videoID-imageName.jpg (eg: pmqzchx-mtc-maxresdefault.jpg)
       
    • I think this change will make it even easier to call the image from the API as you can directly match the image name to the video ID without knowing which one was grabbed. You just need to do a strtolower on the video ID as image names in PW must be lowercase.

I think that's it, but definitely open to additions if you have ideas / code.

EDIT: v0.1.3 limits module to page edit process only - prevents php notices on other admin pages.

Edited by adrian
  • Like 2

Share this post


Link to post
Share on other sites

Another small update. Images now have "video-" prefixed to their filenames. This allows the images field to also store user uploaded images, in addition to the video images. When the module checks for videos that are no longer present on the page, it will no longer delete images that the user has uploaded, unless of course they happen to have "video-" in the filename as well. Hopefully this is a reasonable approach to this. Let me know if it causes anyone any problems and I'll revisit.

  • Like 1

Share this post


Link to post
Share on other sites

I'd like to report this module in addition with Customn Upload Names obviously result in strange things :-)

Cheers!

Share this post


Link to post
Share on other sites

@videokid - thanks for the report.

I have just committed a quick fix for this. I am not sure on the best solution, but the Custom Upload Names module will now ignore any images with an initial filename that contains "youtube" or "vimeo". Of course that means that these won't get renamed at all, but I think that is probably the best behavior at the moment.

Please let me know how it works for you.

EDIT: Just to clarify - it is Custom Upload Names that got the update, not GetVideoThumbs

Edited by adrian
  • Like 1

Share this post


Link to post
Share on other sites

Wow, quick response and action!

Actually I just wanted to report, @the moment it wasn't a very big deal for me. Kinda heads up for future reference.

But because of your quick modification I've tried it out... and it seems to work just fine, so :ThumbsUp: [there should be a emoticon ;) ]

Kind regards!

  • Like 1

Share this post


Link to post
Share on other sites

No worries - we aim to please :)

Thanks again for letting me know about the problem!

  • Like 2

Share this post


Link to post
Share on other sites

Well, while we're at it.... 

Not as much as a problem, something I noticed. I also use the module 'Images With Cropping' [inputfieldCropImage].

I have a field called 'images' and if you select in the 'basics' 'CropImage', the module 'Get Video Thumbnails' doesn't recognize the created field 'images'.

Of course I choose 'images' in the 'basics' and in 'details' I choose Inputfield type 'CropImage'.

I haven't examined both modules [the coding I mean], again, I'm already happy everything works as expected... Could be 'CropImage' shouldn't even be selectable in the basics.

But since I'm in reporting/noticing modus... lol

Again, big appreciation for the work you've done!

  • Like 1

Share this post


Link to post
Share on other sites

Actually, that was an oversight on my part. I have just committed an update so that GetVideoThumbs now supports CropImage fieldtypes, and any other fieldtypes that are an instanceof FieldtypeImage. Before I was limiting it just to FieldtypeImage. 

Let me know if it works ok for you.

As for the configuration options of CropImage - ie changing the fieldtype (basics tab) vs the inputfield (details tab). I haven't tested, but I always assumed you needed to change both. Might be a more appropriate question for the support thread for that module though.

  • Like 2

Share this post


Link to post
Share on other sites

As soon as I have time I will test the update, it works anyhow for the moment. Once the site I'm working on is done and online, I will test on the dev one.

Why you may wonder... it's almost done and I don't want to break things for the moment [you never know]... and on top of that, this is the only 2.4.1 version running atm, so you'll be up-to-speed also.

I had the same assumption btw, but in September/November last year I found out that actually worked... and if it's working, no need fixing things, right?

Will report back ASAP. Thank you already!

Share this post


Link to post
Share on other sites

 "maxresdefault". It is the only one that doesn't get letterboxed, which actually makes it useful, unlike the other ones! 

give mqdefault a try. doesn't get letterboxed for me :)

Share this post


Link to post
Share on other sites

Thanks @woop. I hadn't seen that option before. I just committed a small update that includes that in the default list of thumbnails to grab.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...