Support » Plugin: Media Library Assistant » mp4 videos not being picked up

  • Resolved laymonk

    (@laymonk)


    I am using MLA in conjuction with Photonic to display a gallery selected via media_categories taxonomy.

    I use a shortcode like the following:
    [mla_gallery media_category=’cat1′  post_mime_type=’all’ style=’masonry’ media=’all’]

    I also tried with post_mime_type=’image,video’ but that made no difference ..

    As you can see, I have provided parameters required by both MLA and Photonic for selecting video along with images.

    The biggest challenge is that I am not sure how to confirm whether this issue is coming from MLA or photonic (I am making a similar support post for photonic)

    Any ideas what might be going wrong here ?

    thanks in advance for your help ..

    • This topic was modified 2 years, 2 months ago by laymonk.
Viewing 11 replies - 1 through 11 (of 11 total)
  • I have now isolated the problem:

    MLA picks up the videos but as text URL with no thumbnail associated with them, and that is probably why photonic does not see them ..

    So, this is entirely an issue coming from MLA.

    When I have used photonic directly for media hosted in picassa, it uses the thumbnail defined within picassa .. So, I took it for granted that all usage of video files do the same ..

    Please, how do I get videos to show thumbnails in galleries created with MLA ?

    • This reply was modified 2 years, 2 months ago by laymonk.
    • This reply was modified 2 years, 2 months ago by laymonk.
    • This reply was modified 2 years, 2 months ago by laymonk.

    I have now read through the mla documentation section titled ‘Thumbnail Substitution Support, mla_viewer’ and researched this some more ..

    So, I need to enable thumbnail generation/substitution support .. and use of featured images. then find a way to generate the a thumbnail for each video and set it as featured image

    Found 2 good plugins:
    * https://wordpress.org/plugins/video-thumbnails/ (which needs ffmpeg/libav on the backend)
    * https://wordpress.org/plugins/video-embed-thumbnail-generator/ (which also needs ffmpeg/libav .. but can alternatively use one’s browser for videos that can play natively on browsers)

    I am now using the later plugin to solve this problem.

    This support request can be marked as closed.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your questions and especially for all the work you did to investigate and find a solution for our application. I am very happy that MLA’s Featured Image thumbnail support works with the Video Thumbnails plugin you found. It looks like the [kgvid] shortcode and the id="xxx" parameter in the Video Embed & Tnumbnail plugin can be made to work with MLA’s support for other gallery generating plugins if you need that.

    I am leaving this topic resolved, but please update it if you have any problems or further questions regarding the use of MLA for video-related applications. Thanks for your interest in the plugin.

    Thanks a million for responding.

    It looks like the [kgvid] shortcode and the id=”xxx” parameter in the Video Embed & Tnumbnail plugin can be made to work with MLA’s support for other gallery generating plugins if you need that.

    Yes, please can you add that functionality. I suspect that Photonic might need that as a helper, because currently the thumbnails generated by MLA are not being picked up by Photonic

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the additional information about Photonic support for non-image items. Thanks as well for your positive review; good reviews and positive feedback are great motivators to keep working on the plugin and supporting its users.

    I did some research and discovered that Photonic explicitly limits its galleries to “image” MIME Types. Using some of the WordPress hooks I was able to work around that to add support for video items, including support for MLA’s Featured Image “thumbnails”. It might also work with the Video Thumbnails plugin you are using, but I haven’t tested that.

    I have uploaded a new MLA Development Version dated 20180709 that contains the new feature. To get the Development Version you can follow the instructions in this earlier topic:

    PHP Warning on media upload with Polylang

    It would be great if you can install the Development Version and let me know how it works for you. Thanks for your help and for motivating this new feature.

    Hi David,

    I did some research and discovered that Photonic explicitly limits its galleries to “image” MIME Types.

    Unless I am mistaken WordPress galleries don’t support videos by default, ergo Photonic doesn’t display those. For cases where videos are present in galleries (e.g. Flickr, SmugMug, Picasa, Instagram etc.) Photonic is able to display those fully. To expound on this further, each provider has a different way of dealing with videos (Flickr still uses Flash!), and each lightbox handles different videos differently (Flash is handled differently from embedded URLs, which are handled differently from HTML5 videos). Some galleries have no support for videos at all (e.g. 500px.com and WordPress) – in those cases there isn’t much Photonic can do, but in all other cases there isn’t any restriction by MIME type.

    Basically for WP Photonic is mainly used to display galleries using different layouts, but for everything else integration is written from the ground up.

    The challenge here is that in this specific case the video has been added to a WP gallery via a plugin (i.e. MLA) and Photonic has not been coded for the plugin.

    But … you have had Photonic support for a while, so it is only fair that I should look into adding video support (and hence full support) for MLA. As I mentioned on the other thread though, it will take some time since I am in the middle of a major release.

    OK – based on David’s comment above I took a look and the simplest thing I could come up with at short notice are the following tweaks:

    1. First, in wp-content/plugins/photonic/extensions/Photonic_Native_Processor.php, line 83, you will see this:
      $args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $attr['order'], 'orderby' => $attr['orderby'], 'paged' => $attr['page']);
      Change that to:
      $args = array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => array('image', 'video'), 'order' => $attr['order'], 'orderby' => $attr['orderby'], 'paged' => $attr['page']);
    2. The, a few lines below, in line 147 you will see this:
      $photo_objects[] = $photo_object;
      Right above that line put in:

      if ($wp_details['type'] == 'video') {
      	$photo_object['video'] = $wp_details['url'];
      }

      This will ensure that when you click on a video it plays. However it might not show you a thumbnail for it – to investigate that I have to dig deeper. But if you are seeing thumbnails as well, then one of the other plugins you referenced might have helped.

    Let me know if this works, and I will put it into the next release.

    Plugin Author David Lingren

    (@dglingren)

    @sayontan – thanks for responding and for taking the time to dig into this topic.

    The code I added to support video thumbnails used two WordPress hooks to modify Photonic’s behavior. The first filter I hooked is pre_get_posts, which is applied from the $_attachments = get_posts($args); code on line 89 of Photonic_Native_Processor.php. In this filter I simply remove the post_mime_type query variable, since MLA has already applied it to generate the ids list passed into Photonic.

    The second filter is wp_get_attachment_image_src, which is applied in lines 122 and 123 of the same file:

    $sources[$id] = wp_get_attachment_image_src($id, $main_size, false);
    $thumbs[$id] = wp_get_attachment_image_src($id, $thumb_size);
    

    MLA allows the user to add a “Featured Image” to non-image items such as video and audio clips. The code in my filter returns these “thumbnails”, and Photonic takes it from there. The thumbnail shows up in the gallery. When an item is clicked, the thumbnail opens up in the lightbox. When you click on the caption below the image, the associated Media page allows you to play the audio/video.

    I haven’t done this, but the other patch you suggested right above line 147 could also be handled in the WordPress wp_prepare_attachment_for_js filter called from the $wp_details = wp_prepare_attachment_for_js($id); code on your line 121.

    This topic focuses on video clips, but I have had earlier topics regarding galleries of PDF documents (which do have native thumbnails) in a Photonic gallery. MLA allows the user to compose “galleries” of any MIME type as well as posts and pages. Hardcoding MIME types in your plugin works against these extensions. You might consider additional filters of your own, but so far I’ve been able to use WordPress filters to accomplish my goals.

    Thanks again for your time and input!

    David,
    I do understand what you are saying. However, the hardcoding is actually from the gallery_shortcode function of WP (see wp-includes/media.php, line 1683) – Photonic simply replicates that method (it was almost an exact replica a few WP versions back, but now there are subtle changes). I have to, so that the default behaviour of a gallery is the same as WP’s. In fact I have documented this right above the method you have quoted:

     * We will take the gallery images and do some fun stuff with styling them in other methods. We cannot use the WP function because
     * this code is nested within the gallery_shortcode function and we want to tweak that (there is no hook that executes after
     * the gallery has been retrieved.
    

    (Please ignore the fact that I missed the closing parenthesis above 🙂 )
    If, as per the above, there was a hook in WP executing after the gallery was retrieved, I wouldn’t have had this code in Photonic at all.

    As a matter of fact, the replication of the code is precisely what is letting you use the pre_get_posts filter. As a simple exercise, if you disable Photonic and run the standard WP gallery without the pre_get_posts filter you are not going to get the video.

    The issue here (if you could call it that) is that MLA and Photonic are meant for two different purposes – in MLA you edit the core behaviour of the WP gallery (or rather, write your own version of a gallery with a different shortcode), but in Photonic I don’t. I tweak the output of a gallery and align it with that of other providers. I could have gone crazy trying to do things like albums etc. (a la NextGEN) within WordPress, however that is not the intent of Photonic.

    Photonic’s design intent as a whole has always been different from the beginning and has centered around these 3 things:

    1. It was meant originally purely as a photography plugin, hence the name. I added videos pretty late in the game when users started using the plugin to display family albums with videos. So it still remains a photography plugin but with video support.
    2. No custom shortcodes, but if you have some other plugin overriding the gallery shortcode Photonic lets you set another one up.
    3. WP galleries should behave in a standard manner when Photonic is deactivated.
    4. The plugin should not leave behind shortcodes in the markup when deactivated, even if you are using it to display galleries from say Flickr. Using the gallery shortcode lets me do this, but if someone switches to a custom shortcode that flexibility is lost.

    When an item is clicked, the thumbnail opens up in the lightbox. When you click on the caption below the image, the associated Media page allows you to play the audio/video.

    With the change that I have proposed above line 147 the video will play directly in the lightbox, as it happens with non-WP galleries in Photonic – you will not require a second click to open the media page and then play the video. Photonic tries to keep you within the lightbox (and on the same page) to the extent possible.

    I haven’t done this, but the other patch you suggested right above line 147 could also be handled in the WordPress wp_prepare_attachment_for_js filter called from the $wp_details = wp_prepare_attachment_for_js($id); code on your line 121.

    … Not for showing a video in a lightbox, or for using common code structure across all providers. Bear in mind that WP is currently only one of 8 providers (if you include the now defunct 500px.com) Photonic supports, and a key part of the design is UI consistency across all providers.

    Also regarding your comment about PDF, Photonic has never been intended for showing PDFs in a lightbox. Again, I refer you back to the standard WP gallery – while it is true that PDFs can have a native thumbnail, PDFs are never included in a gallery by WP by default – that is left to other plugins.

    This has been an interesting discussion. As I have mentioned earlier, since you integrate with Photonic’s layouts and lightboxes, I would like to build in explicit support for all media types that you add. That way if people use MLA for WP galleries and Photonic for Google Photos on the same site, the behaviour is going to be consistent. Can you point me to a list of all types of attachments you support?

    @laymonk,
    Since David says he has already handled suggestion #1 using hook in MLA, can you try out suggestion #2 and let me know if that works?

    Plugin Author David Lingren

    (@dglingren)

    @sayontan – Thank you for your detailed explanation of the philosophy behind Photonic’s approach to gallery composition. I appreciate the thought you’ve put in to your work and the clarity of your post describing it. Your decision to tweak the output of the [gallery] rather than to extend or replace it is very sensible. Your description of the strategy and intended market/applications is sound.

    With MLA I have taken a more opportunistic approach. Media Library Assistant was created to improve the Media/Library admin submenu and to add features such as taxonomy support to Media Library items; all items, any MIME type. My original approach to the [mla_gallery] shortcode was to mirror the [gallery] format while adding all of the WP_Query capabilities (like taxonomy queries) to the data selection portion of the process. I added custom style and markup templates to give users a way to alter the gallery format to suit their applications. These objectives meant I could not adopt your priorities of no custom shortcodes, standard behavior after deactivation and leaving no shortcodes behind.

    Like you, I did not want to invest my own effort in advanced gallery display features, lightboxes, albums and so forth. My early support of Photonic and the more general support for other gallery-generating shortcodes is an alternative to duplicating the work of so many other plugin authors.

    Most of the enhancements to MLA over the past few years have come from responding to support requests. I have been amazed at the range of applications that MLA has become a part of and greatly enjoyed working with users to find and support solutions for their needs. As I mentioned, many users want to compose galleries of PDF documents. With the new MLA changes, the thumbnails make a nice-looking gallery and the larger images shown in the lightbox are readable and look good. I don’t know how to open the document itself in the lightbox, of course, but linking to the Media Page isn’t too bad. If that works for a user’s application I am happy.

    You are right that filtering wp_prepare_attachment_for_js doesn’t help for showing video in the lightbox (my mistake). I tried your “suggestion #2”, adding the code you gave just above line 147. As predicted, the video plays directly in the lightbox for Chrome and Firefox browsers; it does not work in Microsoft Edge on my system. I also noticed that it only works if you click in the middle of the lightbox window. If you click the play/pause control in the lower-left corner the “previous item” action is executed instead. Finally, the video “Thumbnail” image does not appear in the player when viewed in the lightbox. The image DOES appear when the player is embedded in the Media Page for the item. I don’t think that is too important.

    The same fix works for audio files as well, but you have to assign the URL to $photo_object['video'] in both cases.

    You wrote:

    I would like to build in explicit support for all media types that you add. That way if people use MLA for WP galleries and Photonic for Google Photos on the same site, the behavior is going to be consistent. Can you point me to a list of all types of attachments you support?

    As I outlined above, [mla_gallery] works for all post_mime_type and post_type values. As a “photography plugin but with video support“, Photonic seems like a good solution for image, video AND audio MIME types. I don’t see how you could support other MIME and post types without compromising your design goals. If you add this patch above line 47 I think you’ve done what you can:

    if ( $wp_details['type'] == 'video' || $wp_details['type'] == 'audio' ) {
    	$photo_object['video'] = $wp_details['url'];
    }
    

    I welcome any further thoughts and suggestions you might have. Thanks again for a stimulating and useful dialog!

    Wow, thanks David & Sayontan for having these insightful conversations.

    I have now installed the dev version of MLA, and made the code changes suggested by Sayontan on Photonic ..

    • MLA is now using the mime-type icon (where a featured image is absent) for videos.
    • Photonic is indeed playing the videos, right within the lightbox. The initial popup get’s in the way and needs to be closed, but I think Photonic has a setting to deal with this initial pop-up.

    So, certainly between the both of you, you have helped resolve this need of mine .. I am mighty grateful for that.

    PS: Sayontan, supporting PDFs that link to media files will be very useful for some use cases.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘mp4 videos not being picked up’ is closed to new replies.