The reason for the media uploader not opening when clicking the second button is that both of your buttons have the same ID, which you are also binding to the function that open your uploader. Element IDs should always be unique, hence the .click function listener will only detect when user clicks the first button (=first one with id=”image-url”). To solve this problem, try assigning a common class for both buttons, and bind the media uploader function to that class.
You will run in the same problem upon selecting the image for your BG Image, as both your outer inputs have also same ID (“image-url”), meaning the BG image will be assigned to Logo image. To get around this problem, you could use jQuery tree traversing functions to get the parent of your current input button and call the .val(attachment.url) on that element.
Related Posts:
- Add tinymce buttons to caption textarea in media uploader
- Extend 3.5 media uploader plugin to change button name
- How to change the text of the “You are about to permanently delete these items…” alert message when deleting media from the media library?
- Using WordPress 3.5 Media Uploader in meta box?
- Display Media Uploader in Own Plugin on WordPress 3.5
- WordPress AJAX File Upload – FrontEnd
- How to get attachment id as soon as it is uploaded through media uploader in jquery?
- How to handle multiple instance of “send_to_editor” js function
- Custom function to rearrange attachments when creating posts – Almost there
- Media manager multiple selection
- 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
- Limit filetype and wp media
- Passing jQuery into the WordPress media uploader
- Send multiple attachments with JQuery and wp_mail() function
- Yoast SEO breaking media upload
- Adding URL of PDF from Thickbox in a Meta Box
- 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?
- Edit Image/Image Details – Replace button missing
- jQuery form plugin, submit in the wordpress way
- $.ajax – dataType
- Bootstrap – Uncaught TypeError: Cannot read property ‘fn’ of undefined
- How to use jQuery qTip?
- javascript function wait until another function to finish
- Clear form fields with jQuery
- How can I change the text color with jQuery?
- ajax stopped working when not logged in?
- Is there a way to enable Cross-Origin Resource Sharing for WordPress’ ajaxurl?
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- Using ‘$’ instead of ‘jQuery’ in WordPress
- jQuery and AJAX Not working with Select Form Element
- Force wp_enqueue_scripts to the HEADER?
- Is it possible to get the logged in username in a jquery script?
- Gravity Forms loading jquery
- WordPress and jQuery [closed]
- Any good lightbox-like option that works in WP 3.2.1?
- Javascript included but alert() function not working
- Bind to WPSetAsThumbnail
- Disable collapse of admin meta boxes
- How do I activate jQuery/script on demand?
- How to delete post attachments when jQuery is used with a click event on the delete link
- I need a Simple image uploader with a simple screen. WP default has too many options.
- How to properly add Bootstrap and JQuery Javascripts?
- How to delete uploads not in media library?
- Using jQuery to retrieve customizer value
- WordPress ajax function parameter value not being passed
- Is it safe to include a javascript file in a template’s php file?
- Site icons with alpha channel for self-hosted WordPress blog network
- Using subdomain to upload media/images etc on 2 different blogs
- Masonry and Jetpack Infinite Scroll – overlap issue
- Dealing with a library that depends on jQuery
- How can I load jquery library into my dashboard widget?
- Accessing user Meta data via REST and backbone
- Capability to prevent upload of files
- Passing a varible from jQuery to PHP
- Vanderlee jQuery color picker and WordPress Errors
- How to add meta box for image upload using WordPress media uploader?
- Gutenberg – Title field required
- Adding a slide toggle on WordPress
- wp.media issue with selected image
- How to retrieve WP_Object that is inside an array of another array
- WP Customizer: Save a control state
- limit media upload to once a day
- Getting jQuery AJAX to work in WordPress (getting -1)
- Custom Jquery in admin breaks media-upload script
- jQuery Drill Down iPod Menu FOUC and Selecting Current page
- Absolute path to stylesheet_dir/images/my_img.jpg does not work?
- Which hook to use when adding ajax to viewer-facing side?
- WordPress and Modal Popup – how to make the already loaded javascript assets available in modal?
- jquery.min has very long TTFB
- animate.style on wp-login.php
- Missing a temporary folder not fixed
- Theme style overrides the plugin style
- Form validation before submitting
- How to Protect Uploads, if User is not Logged In?
- wp_delete_attachment doesn’t delete image files / doesn’t work
- Media URL slugs without uploads folder path
- Frontend media shows “An error occurred in the upload. Please try again later.”
- Special Characters and Spaces are not transferred correctly via AJAX call.
- How to manipulate elements on the Insert Media Attachment settings popup
- Site images are fixed in front of my site content [closed]
- Theme stops media uploader from working
- Running javascript in a child theme. Works in jsfiddle
- How to block action if post is “dirty”?
- $ not defined using jQuery in WordPress
- WordPress media upload multiple images
- Auto Select Child categories on Multiple Dropdown – Jquery
- adding the full image path to a wordpress javascript file
- jQuery Live Form Validation in WordPress
- Ensure an external javascript file called from plugin is loaded after jquery is called
- jQuery not working for tabs shortcode [closed]
- Why my vertical tab js code is refreshing the page continuously? [closed]
- bootstrap-slider.js by seiyria not working in wordpress
- Contact Form 7 – Submit Form not working After Ajax Request [closed]