Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:53:35+00:00 2026-05-28T14:53:35+00:00

I have a post type which is used to upload banners in wordpress. Using

  • 0

I have a post type which is used to upload banners in wordpress. Using custom fields for name, image/video and url. The default media upload works fine to upload image/videos, but my problem is I cannot get the video base url to the custom field.

Here is my code that is not able to get the video url. It only gives me video file name.

window.send_to_editor = function(html) {

    var imgurlar = html.match(/<img[^>]+src=\"([^\"]+)\"/);
    var imgurl = imgurlar[1];

    //image
    if( imgurl.length ){
        jQuery('#wsp_media').val(imgurl);
        jQuery('#preview-wsp-media').html('<img src="'+imgurl+'" style="max-width:30px; max-height:50px"/><input type="button"  value="Remove" class="button" onclick="removeUspMedia()"/>');
    }
    //video
    else{
        var fileurl = jQuery(html);
            //above "html" carries only video name if I click on "none" button in media library

        //check if fileurl is a video ??
        var fName = jQuery(fileurl).attr('href');

        ext = fName.split('.').pop().toLowerCase();
        var validVideos = [<?php echo "'" . implode("','", explode(' ', $this->validVideos)) . "'"?>];
        if(jQuery.inArray(ext, validVideos) == -1){
            alert('invalid video file selected');
        }else{
            jQuery('#wsp_media').val(fName);
            jQuery('#preview-wsp-media').html('<img src="<?php bloginfo('url')?>/wp-includes/images/crystal/video.png" style="max-width:30px; max-height:50px"/><input type="button"  value="Remove" class="button" onclick="removeUspMedia()"/>');
        }
    }
    tb_remove();

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:53:36+00:00Added an answer on May 28, 2026 at 2:53 pm

    I have found the solution myself.

    Add a filter in “media_send_to_editor”

    add_filter('media_send_to_editor', 'media_editor', 1, 3);
    

    Append the video url in output html

    function media_editor($html, $send_id, $attachment ){
        //get the media's guid and append it to the html
        $post = get_post($send_id);
        $html .= '<media>'.$post->guid.'</media>';
        return $html;
    }
    

    Get the media url like this

    window.send_to_editor = function(html) {
            .......
            .......
            var pathArray = html.match(/<media>(.*)<\/media>/);
            var mediaUrl = pathArray != null && typeof pathArray[1] != 'undefined' ? pathArray[1] : '';
            jQuery('#wsp_media').val(mediaUrl);
            .......
            .......
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://demo.thethemefoundry.com/traction/#post-183 Which wordpress plugin is this, to have post image on the left side
Let's say I have the following jQuery AJAX call: $.ajax({ type: POST, url: MyUrl,
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have the following javascript: $.ajax({ type: "POST", dataType: "json", url: "/Home/Submit", data: {
I have a simple ajax call like this: $.ajax({ url: u, type: POST, dataType:
I have such an issue var url = index.php?id=123&sid=321; $.ajax({ type: POST, url: some.php,
I have 2 tables (Wordpress Database), one which stores posts and the other post
I have to POST some parameters to a URL outside my network, and the
I have a user control which is called MyControl. And it is used in
I am using JQuery. I have below JQuery Code which working fine in Firefox,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.