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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By MoritzLost
      This is a new module that provides a simple solution to clearing all your cache layers at once, and an extensible interface to perform various cache-related actions.
      The simple motivation behind this module was that I was tired of manually clearing caches in several places after deploying a change on a live site. The basic purpose of this module is a simple Clear all caches link in the Setup menu which clears out all caches, no matter where they hide. You can customize what exactly the module does through it's configuration menu:
      Expire or delete all cache entries in the database, or selectively clear caches by namespace ($cache API) Clear the the template render cache. Clear out specific folders inside your site's cache directory (/site/assets/cache) Refresh version strings for static assets to bust client-side browser caches (this requires some setup, see the full documentation for details). This is the basic function of the module. However, you can also add different cache management action through the API and execute them through the module's interface. For this advanced usage, the module provides:
      An interface to see all available cache actions and execute them. A system log and logging output on the module page to see verify what the module is doing. A CacheControlTools class with utility functions to clear out different caches. An API to add cache actions, execute them programmatically and even modify the default action. Permission management, allowing you granular control over which user roles can execute which actions. The complete documentation can be found in the module's README.
      Beta release
      Note that I consider this a Beta release. Since the module is relatively aggressive in deleting some caches, I would advise you to install in on a test environment before using it on a live site.
      Let me know if you're getting any errors, have trouble using the module or if you have suggestions for improvement!
      In particular, can someone let me know if this module causes any problems with the ProCache module? I don't own or use it, so I can't check. As far as I can tell, ProCache uses a folder inside the cache directory to cache static pages, so my module should be able to clear the ProCache site cache as well, I'd appreciate it if someone can test that for me.
      Future plans
      If there is some interest in this, I plan to expand this to a more general cache management solution. I particular, I would like to add additional cache actions. Some ideas that came to mind:
      Warming up the template render cache for publicly accessible pages. Removing all active user sessions. Let me know if you have more suggestions!
      Links
      https://github.com/MoritzLost/ProcessCacheControl ProcessCacheControl in the Module directory

    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="optin" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="optin" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="optin" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: https://github.com/blaueQuelle/privacywire/tree/master
      Download: https://github.com/blaueQuelle/privacywire/archive/master.zip
      I would love to hear your feedback 🙂
      Edit: Updated URLs to master tree of git repo
       
    • By David Karich
      Admin Page Tree Multiple Sorting
      ClassName: ProcessPageListMultipleSorting
      Extend the ordinary sort of children of a template in the admin page tree with multiple properties. For each template, you can define your own rule. Write each template (template-name) in a row, followed by a colon and then the additional field names for sorting.
      Example: All children of the template "blog" to be sorted in descending order according to the date of creation, then descending by modification date, and then by title. Type:
      blog: -created, -modified, title  Installation
      Copy the files for this module to /site/modules/ProcessPageListMultipleSorting/ In admin: Modules > Check for new modules. Install Module "Admin Page Tree Multible Sorting". Alternative in ProcessWire 2.4+
      Login to ProcessWire backend and go to Modules Click tab "New" and enter Module Class Name: "ProcessPageListMultipleSorting" Click "Download and Install"   Compatibility   I have currently tested the module only under PW 2.6+, but think that it works on older versions too. Maybe someone can give a feedback.     Download   PW-Repo: http://modules.processwire.com/modules/process-page-list-multiple-sorting/ GitHub: https://github.com/FlipZoomMedia/Processwire-ProcessPageListMultipleSorting     I hope someone can use the module. Have fun and best regards, David
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "https://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


×
×
  • Create New...