I have problem with getting image url from media upload wordpress after clicking insert into post. I want to save this url to the value of the hidden field id: "pims-slide-url" and insert in the paragram id "slide-preview" img tag with the src attribute set to the getted image url of the 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, as I was stuck with this code.