adrian Posted September 28, 2013 Share Posted September 28, 2013 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 13 Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2013 Author Share Posted September 28, 2013 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 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 28, 2013 Share Posted September 28, 2013 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. Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2013 Author Share Posted September 28, 2013 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! 1 Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2013 Author Share Posted September 28, 2013 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. Link to comment Share on other sites More sharing options...
Zahari M. Posted September 28, 2013 Share Posted September 28, 2013 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 Anyways... can't wait to try this module and see how it works! Thank you Adrian !!!!!!! 1 Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2013 Author Share Posted September 28, 2013 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 1 Link to comment Share on other sites More sharing options...
Zahari M. Posted September 28, 2013 Share Posted September 28, 2013 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!!!!!!! :-) Link to comment Share on other sites More sharing options...
adrian Posted September 28, 2013 Author Share Posted September 28, 2013 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. Link to comment Share on other sites More sharing options...
Zahari M. Posted September 29, 2013 Share Posted September 29, 2013 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! Link to comment Share on other sites More sharing options...
adrian Posted October 6, 2013 Author Share Posted October 6, 2013 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. 1 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 6, 2013 Share Posted October 6, 2013 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 ? Link to comment Share on other sites More sharing options...
adrian Posted October 7, 2013 Author Share Posted October 7, 2013 (edited) 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 nowif 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 October 8, 2013 by adrian 2 Link to comment Share on other sites More sharing options...
Martijn Geerts Posted October 7, 2013 Share Posted October 7, 2013 Well Done ! Thank you very much ! Link to comment Share on other sites More sharing options...
adrian Posted October 13, 2013 Author Share Posted October 13, 2013 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. 1 Link to comment Share on other sites More sharing options...
videokid Posted April 10, 2014 Share Posted April 10, 2014 I'd like to report this module in addition with Customn Upload Names obviously result in strange things Cheers! Link to comment Share on other sites More sharing options...
adrian Posted April 10, 2014 Author Share Posted April 10, 2014 (edited) @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 April 10, 2014 by adrian 1 Link to comment Share on other sites More sharing options...
videokid Posted April 11, 2014 Share Posted April 11, 2014 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! 1 Link to comment Share on other sites More sharing options...
adrian Posted April 11, 2014 Author Share Posted April 11, 2014 No worries - we aim to please Thanks again for letting me know about the problem! 2 Link to comment Share on other sites More sharing options...
videokid Posted April 11, 2014 Share Posted April 11, 2014 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! 1 Link to comment Share on other sites More sharing options...
adrian Posted April 11, 2014 Author Share Posted April 11, 2014 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. 2 Link to comment Share on other sites More sharing options...
videokid Posted April 11, 2014 Share Posted April 11, 2014 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! Link to comment Share on other sites More sharing options...
woop Posted April 12, 2014 Share Posted April 12, 2014 "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 Link to comment Share on other sites More sharing options...
adrian Posted April 12, 2014 Author Share Posted April 12, 2014 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. Link to comment Share on other sites More sharing options...
vxda Posted April 26, 2014 Share Posted April 26, 2014 Hi Adrian i think i found a bug in your module.its not working when in the link there is "#t=50". Example:https://www.youtube.com/watch?v=aBEEnbXZMwo#t=50 #t=50 is the time, on which player starts the video. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now