This line…
imgurl = jQuery('img',html).attr('src');
Means that jQuery is getting the “source” (i.e. full path) of the image. As you’ve guessed, that won’t work for a PDF file.
What you’ll probably have to do is get the id
of the attachment instead. Could you possibly update your original answer with the HTML SOURCE of the thickbox? We might be able to find the ID from somewhere and amend that jQuery line.
Once you’ve got the ID of the attachment, you can use the following code to display the URL in your HTML whether it’s an image or any other type of attachment:
<?php wp_get_attachment_url( $id ); ?>
Hope that helps.
Related Posts:
- Using WordPress 3.5 Media Uploader in meta box?
- WordPress AJAX File Upload – FrontEnd
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- Add tinymce buttons to caption textarea in media uploader
- Adding jquery and thickbox to WordPress theme
- Lightbox popup on WooCommerce add_to_cart action
- Using the WordPress Media Library and returning the Attachment ID rather than URL?
- How to handle multiple instance of “send_to_editor” js function
- WordPress: Sortable Metabox Fields Not Saving Position
- Using media-upload.php to upload mp3 via custom fields
- How to reload a select box of posts dynamically?
- Extend 3.5 media uploader plugin to change button name
- Add X meta box inputs based on form at top of meta box, how to do it right?
- Unbind postbox click handler
- Disable collapse of admin meta boxes
- Script dependencies for post.js
- validate a metabox based on the category that is selected
- WP Media uploader loading only once in options page
- Edit single attachment on click (WP-admin)
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- Combining media queries with image sizes
- Is it possible to hide media details sidebar when wp.media popup is being opened?
- Getting all URLs of uploaded images using media uploader
- Use Media Uploader on Multiple Images on same page
- Front-end Ajax File Upload
- Hide metabox dependant on page template chosen
- Using WP_Query to grab custom meta values, foreach to json object
- Send multiple attachments with JQuery and wp_mail() function
- Good Solution for Adding jQuery Tabs Anywhere Within WordPress?
- Yoast SEO breaking media upload
- delete post meta by AJAX
- include shortcode values in Thickbox form
- How to use media upload on metabox post page without breaking TinyMCE?
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- How do I make Contact Form 7 pop up in thickbox? [closed]
- Custom Jquery in admin breaks media-upload script
- How to modify iFrame content in an admin thickbox
- wp not defined at wp.Uploader.prototype
- wordpress file upload from direct directory not working
- wordpress ajax upload media not working
- Why does my media selection script write to ONLY the first input field?
- Disable drag metaboxes, create many functions using js not to work!
- JQuery multiple toggle values
- Add text to metabox input text field from Thickbox
- jQuery form plugin, submit in the wordpress way
- Override default options in plugin metaboxes
- How to change the text of Publish Button
- JavaScript sleep/wait before continuing [duplicate]
- JSON parsing error syntax error unexpected end of input
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How do I link a JavaScript file to a HTML file?
- What does [object Object] mean? (JavaScript)
- jQuery $(this) keyword
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- How to set time delay in javascript
- Disable button in jQuery
- jQuery $(this) keyword
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- Disable button in jQuery
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- How to wait 5 seconds with jQuery?
- Submit a form using jQuery
- How to Handle Button Click Events in jQuery?
- How to enable CORS in flask
- How can I get the ID of an element using jQuery?
- jQuery equivalent of JavaScript’s addEventListener method
- Should I use .done() and .fail() for new jQuery AJAX code instead of success and error
- Pass request headers in a jQuery AJAX GET call
- $.ajax – dataType
- what does jQuery data() function do
- How to show loading spinner in jQuery?
- How can I get the ID of an element using jQuery?
- What is content-type and datatype in an AJAX request?
- jQuery Selector: Id Ends With?
- speedtest.net api
- jQuery dialog popup
- data.map is not a function
- How do you select a particular option in a SELECT element in jQuery?
- Set select option ‘selected’, by value
- Change Placeholder Text using jQuery
- Adding placeholder attribute using Jquery
- jQuery Ajax error handling, show custom exception messages
- How to send multiple data fields via Ajax?
- Adding an onclick function to go to url in JavaScript?
- Checking a Url in Jquery/Javascript
- Jquery change background color
- My javascript is returning this error: $.ajax is not a function
- Best way to store a key=>value array in JavaScript?
- jQuery if div contains this text, replace that part of the text
- Javascript Runtime error: $ is undefined
- Bootstrap – Uncaught TypeError: Cannot read property ‘fn’ of undefined
- jQuery set checkbox checked
- JavaScript: filter() for Objects
- What is different between $(document).on() and $(element).on()
- JavaScript runtime error: ‘$’ is undefined
- When and why to ‘return false’ in JavaScript?
- How to use jQuery qTip?
- Installing jQuery?
- Email validation using jQuery
- Order of $(document).load() and $(document).ready() when deferring loading js