• This works fine, it hops to the media library and lets me select an image

    <input type="text"   name="vimage_url" id="vimage_url"  readonly class="regular-text" value="'.$current_grouplogo.'" />
    <input type="button" name="upload-btn" id="upload-btn" class="button-secondary" value="Video from media library">

    but if i repeat the code in my custom post type meta box for a second image upload on the same form, clicking does nothing.

    Any ideas please?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I was hoping someone else would come along with a suggestion, as nearly anything would be better than my wild guess. Any direction, no matter the lack of surety, is better than no direction? ??

    You cannot copy that code to elsewhere on the same page without at least some adjustment of the ID attribute. There should not be more than one element on a page with the same ID. The media library is opened with a jQuery script. Here’s the guessing part: The event listener gets attached to the first element found having a certain ID. No further searching of IDs occur since there should not be more than one, so yours gets ignored.

    You need your own ID and some script that adds a listener to your element (or the jQuery equivalent). Whatever callback the event triggers can be the same, but your element needs its own listener.

    If the media library script is triggered through a selector other than by element ID, my theory falls apart. Even if wrong, adding your own listener for your element that uses the same callback to open the library as the others do should be a workable approach. I’m afraid I don’t know what that callback is. Find the right one and this approach will work.

Viewing 1 replies (of 1 total)
  • The topic ‘Uploading images with upload-btn’ is closed to new replies.