Forums

[resolved] meta box custom fields with images uploader (3 posts)

  1. cosimo
    Member
    Posted 1 year ago #

    Hi, i'm tryin to create a custom fields in post writing page with add_meta_box. What I want to do is a meta box with an image loader that also allows me to preview the image. If I could also use the wordpress media gallery fot this would be even better. Excuse me for my bad english

  2. cosimo
    Member
    Posted 1 year ago #

    I solved with this:

    jQuery(document).ready(function () {
    jQuery('#bottone_carica_anteprima').click(function () {
    formfield = jQuery('#carica_anteprima');
    post_id = jQuery('#post_ID').val();
    tb_show('', 'media-upload.php?post_id=' + post_id + '&type=image&TB_iframe=true');
    return false;
    });
    window.send_to_editor = function (html) {
    imgurl = jQuery('img', html).attr('src');
    jQuery('#carica_anteprima').val(imgurl);
    tb_remove();
    }
    jQuery('#bottone_carica_foto').click(function () {
    formfield = jQuery('#carica_foto');
    post_id = jQuery('#post_ID').val();
    window.send_to_editor = window.send_to_editor_clone;
    tb_show('', 'media-upload.php?post_id=' + post_id + '&type=image&TB_iframe=true');
    return false;
    });
    window.send_to_editor_clone = function (html) {
    imgurl = jQuery('img', html).attr('src');
    jQuery('#carica_foto').val(imgurl);
    tb_remove();
    }
    });

    Found here

  3. bhorner
    Member
    Posted 8 months ago #

    Where do you put this code? Which php file?

Topic Closed

This topic has been closed to new replies.

About this Topic