Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I ran into this same issue.

    I was able to output photos by using the WordPress call get_post_meta. First check to see if there are images, then unserialize the array and strip out the quotations.

    Then I just wrote a simple foreach loop to insert each one of my saved images into an image tag.

    Paste the following within your WP loop and that should do the trick!

    <?php if ( get_post_meta( get_the_ID(), 'miu_images', true ) ) : ?>
        <?php
        $array = unserialize(get_post_meta( get_the_ID(), 'miu_images', true ));
        $images = str_replace('"', "", $array);
        ?>
            <?php foreach( $images as $image ) : ?>
    
                <img class="thumb" src="<?php echo $image; ?>" alt="<?php the_title(); ?>" />
    
    	<?php endforeach; ?>
    <?php endif; ?>
    Thread Starter ch6x

    (@ch6x)

    It seems this is still an issue for me, but I decided to just add hidden inputs to remedy.

    I wanted to display the image rather than the input with file url. Amended mui_script.js line 31 to insert url into my hidden input and image tags, then added new tags to emptyRowTemplate.

    Before:

    window.original_send_to_editor = window.send_to_editor;
        window.send_to_editor = function(html){
            if (formfield) {
                fileurl = jQuery('img',html).attr('src');
    
                jQuery('#img-'+img_id).val(fileurl);
    
                tb_remove();
    
                jQuery('html').removeClass('Image');
    
            } else {
                window.original_send_to_editor(html);
            }
        };
    });
    
    function addRow(image_url){
        if(typeof(image_url)==='undefined') image_url = "";
        itemsCount+=1;
        var emptyRowTemplate = '<div id=row-'+itemsCount+'> <input style=\'width:70%\' id=img-'+itemsCount+' type=\'text\' name=\'miu_images['+itemsCount+']\' value=\''+image_url+'\' />'
        +'<input type=\'button\' href=\'#\' class=\'Image_button button\' id=\'Image_button-'+itemsCount+'\' value=\'Upload\'>'
        +'<input class="miu-remove button" type=\'button\' value=\'Remove\' id=\'remove-'+itemsCount+'\' /></div>';
        jQuery('#miu_images').append(emptyRowTemplate);
    }

    After:

    window.original_send_to_editor = window.send_to_editor;
        window.send_to_editor = function(html){
            if (formfield) {
                fileurl = jQuery('img',html).attr('src');
    
                jQuery('#img-'+img_id).attr('value', fileurl);
    
                jQuery('#imgupld-'+img_id).attr('src', fileurl);
    
                tb_remove();
    
                jQuery('html').removeClass('Image');
    
            } else {
                window.original_send_to_editor(html);
            }
        };
    });
    
    function addRow(image_url){
        if(typeof(image_url)==='undefined') image_url = "";
        itemsCount+=1;
        var emptyRowTemplate = '<div id=row-'+itemsCount+'><input id=img-'+itemsCount+' type=\'hidden\' name=\'miu_images['+itemsCount+']\' value=\''+image_url+'\' />'
        +'<img src=\''+image_url+'\' name=\'miu_images['+itemsCount+']\' style=\'width:25%; padding: 2%;\' id=imgupld-'+itemsCount+' />'
        +'<input type=\'button\' href=\'#\' class=\'Image_button button\' id=\'Image_button-'+itemsCount+'\' value=\'Upload New Image\' style=\'margin:2% 5px;\' >'
        +'<input class="miu-remove button" type=\'button\' value=\'Remove Image\' id=\'remove-'+itemsCount+'\' style=\'margin:2% 5px;\' /></div>';
        jQuery('#miu_images').append(emptyRowTemplate);
    }

    Works great now. FYI for anyone trying to accomplish the same thing here!

Viewing 2 replies - 1 through 2 (of 2 total)