Viewing 2 reply threads
  • Author
    Posts
    • #7354
      bicho44
      Member

      Hi:

      Maybe is a little over kill, but i need to use a URL to upload a video preview url (right know, a Youtube Preview image)
      Im already can obtain the URL, but i need to insert as a Thumbnail image, so i can use it as preview image in the archive.
      But, i can found how to do that.
      I think maybe i can use that url as a base to the upload function, but im stuck.
      Any help could be appreciate.
      The Code i have.

      piklist (
          'field',
          array(
              'type' => 'text',
              'scope' => 'post_meta',
              'field' => 'imgd_programa_video',
              'label' => __('Link Youtube', 'imgd'),
              'value' => '',
              'attributes' => array(
                  'class' => 'text'
              ),
              'position' => 'wrap'
          )
      );
      
      ?>
      <script>
      jQuery(document).ready(function( $ ) {
        $("#_post_meta_imgd_programa_video_0").on('change',function () {
           var ytl = $( "#_post_meta_imgd_programa_video_0" ).val();
           var yti = ytl.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
      
      //This is the post thumbnail, but...
           $('_post_meta__thumbnail_id_0').value("http://i3.ytimg.com/vi/"+ yti[1] + "/hqdefault.jpg");
           
        });
      });
      </script>
      
      <?php
      
      piklist('field', array(
          'type' => 'file'
          ,'field' => '_thumbnail_id' // Use these field to match WordPress featured images.
          ,'scope' => 'post_meta'
          ,'options' => array(
              'title' => __('Imagenes del Show', 'imgd')
              ,'button' => __('Inserte las imagenes', 'imgd')
          )
      ));
    • #7376
      Steve
      Keymaster

      You want to add a YouTube url to imgd_programa_video, and then use the YouTube thumbnail as the preview in admin?

    • #7379
      bicho44
      Member

      Hi @steve:

      Yes, the idea is add the Youtube link in a text field, and capture the Image youtube serve as a thumbnail, and then download that image into the media library, and assign it as feature image for the CPT. LOL 😀

      I know, i know, is a lot, but i think i can use the functions who use the upload field as a helper to download and then set the feature image.

      As I said any pointer…

      Best regards

Viewing 2 reply threads
  • You must be logged in to reply to this topic.