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
- jQuery $(this) keyword
- jQuery Selector: Id Ends With?
- jQuery dialog popup
- jquery loop on Json data using $.each
- Click button copy to clipboard
- $(document).on(“click”… not working?
- How to read data From *.CSV file using javascript?
- jQuery get the image src
- how to define variable in jquery
- Enqueue core jQuery in the footer?
- How to correctly include jquery-ui effects on wordpress
- Check if user is logged in using JQuery
- How to prevent WordPress from loading the jQuery library at the top of the page
- Including javascript for a shortcode
- adding the full image path to a wordpress javascript file
- Unable to run jQuery script in my template file
- Dropzonejs with WPCF7 [closed]
- gravity forms jQuery.load into modal [closed]
- jQuery.accordion isn’t a function even when enqueued
- How Can I Add “New” Lazy Load Images To NewsPaper WP Theme? [closed]
- WooCommerce Ajax Cart Update Stopped Working
- WordPress AJAX Load More function duplicating a post
- Plugins loading multiple copies of JQuery
- What is the propre way to include jQuery UI Datepicker’s CSS in plugin?
- How register library to use jquery correct
- How do I translate string inside jQuery script with WPML?
- Using Foundation 5 in WordPress Administration Area
- Wp theme Jquery conflict with plugins that use jquery
- Loading external jQuery files with $
- fill form fields with ajax response
- Adding custom cart price with Ajax in wordpress
- Bootstrap modal with jQuery post [closed]
- echo do_shortcode for Contact Form 7 from within dynamically loaded php file
- Showing Meta Box via Jquery Checkbox
- How to declare/provide file path in JQuery which is emeeded in the WordPress theme
- How to set javascript options for select2 in PHP array of plugin
- Show More Show Less – Not Working
- How to make JQuery load on top of head tag before everything
- Trying to add google ad onclick to wordpress and Divi buttons and header link
- jQuery Plugin Uncaught TypeError: jQuery(…).slider is not a function
- How to use jQuery plugin
- $_POST empty in using new php file added to theme
- How to blur the_post_thumbnail() via blur.js (jquery)?
- Generating image sizes when uploading through wp.media
- Uncaught TypeError: Cannot read property ‘ajax’ of undefined
- :first-child applying to all links [closed]
- Toggle a metabox based on a selection
- Add jQuery function to media button
- Why won’t this jQuery work in WordPress?
- jQuery color picker function on change
- Can’t get this jQuery snippet to work with WordPress
- Javascript Loading Effect to URLs
- jQuery Add/Remove Classes Not Working
- Making the Google Maps API non readable