jquery - How to run a preview from apload media and add image url to hidden field value in wordpress custom plugin -


i have problem getting image url media upload wordpress after clicking insert post. want save url value of hidden field id: "pims-slide-url" , insert in paragram id "slide-preview" img tag src attribute set getted image url of media uploads.

excerpt of form:

<th>                     <label for="pims-slide-url">slide:</label>                     </th>                     <td>                         <a class="button-secondary" id="select-slide-btn">wybierz slajd z biblioteki mediów</a>                         <input type="hidden" name="entry[slide_url]" id="pims-slide-url" />                     <p class="description">to pole jest wymagane</p>         <p id="slide-preview"></p>                     </td>              </tr> 

and jquery code is:

(function($){         $(document).ready(function(){           window.send_to_editor = function(html){          var img_url = $('img',html).attr('src');         $('#pims-slide-url').val(img_url);          tb_remove();           var $previmg = $('<img>').attr('src', img_url);          $('#slide-preview').empty().append($previmg);     };                 $('#select-slide-btn').click(function(){             //uruchomienie iframe z biblioteką mediów              var url = 'media-upload.php?tb_iframe=true&type=image';                tb_show('wybierz slajd', url, false);              return false;         });     });   })(jquery); 

please help, stuck code.

   window.send_to_editor = function(h)     {         $('#slide-preview').empty().html(h);                 tb_remove();                 $('#pims-slide-url').val($('#slide-preview img').attr('src'));  } 

this code working...


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -