• Resolved cynexz

    (@cynexz)


    Hello,

    I’m having some problems with this plugin.

    The plugin works fine in the back-end. I can add images, it saves them. It’s all ok.

    The problem is I can’t get the images to show on the site itself..

    The code I use is:

    <?php
    get_images_ids(true,id);
    // 2 accepted parameter : thumbnail (BOOLEAN), and id (to target a specific post)
    // if thumbnail = true, join the id of the post thumbnail at the front of the returned array
    
    //An exemple of output
    array(
        [0]  => 45,
        'image1' => 5,
        'image2' => 6,
        'image3' => 12,
        'image6' => 20,
        'image7' => 15
    );
    
    //Empty pictures ar not returned
    ?>

    It gives me an error on the line of the beginning of the array: [0].

    On all the other codes snippets of this plugin it also gives me an error on [0] of array:

    Warning: Illegal offset type in C:\xampp\htdocs\autotest\wp-content\themes\twentytwelve\single.php on line 39

    Can someone also explain me what the numbers mean after each array item?

    https://www.ads-software.com/extend/plugins/multi-image-metabox/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Willy Bahuaud

    (@willybahuaud)

    Hello,

    If you want to retrieve the IDs of the linked pictures, juste do something like :
    $all_my_ids = get_image_ids();
    $all_my_ids will now contain all the IDs of the images (and you can do what you want with this…)

    If you want to print these picts, you can also use get_images_scr() like that :

    foreach(get_images_src() as $k => $i){
    echo '<img src="'.$i[0].'" width="'.$i[1].'" height="'.$i[2].'" />';
    }

    …and all linked files will be printed.

    Do I have answered correctly your questions ?

    Maybe the plugin documentation is too light :-/

    Thread Starter cynexz

    (@cynexz)

    Thank you for your fast response.

    I am not really good at php so I did not fully understand you documentation.

    What I have found working was:

    <?php
    $args = array(
    'post_type' => 'attachment',
    'post_mime_type' => 'image',
    'post_parent' => $post->ID
    );
    $images = get_posts( $args );
    foreach($images as $image): ?>
    <a rel="lightbox" href="<?php echo wp_get_attachment_url($image->ID); ?>" title="<?php echo wp_specialchars( get_the_title($image->ID), 1 ) ?>"><?php echo wp_get_attachment_image($image->ID, 'medium' ); ?></a>
    <?php endforeach;
    ?>

    I found out that with this plugin, it just adds images as attachments. So I found this code to just show all the attachments.

    I love your plugin, and it works fine now. Thank you very much.

    Maybe you could update the documentation for the people that also had the same problem as me and do not know what to do.

    Keep up the great work ??

    I had the same problem, but thanks to cynexz i could solve it =D

    Plugin Author Willy Bahuaud

    (@willybahuaud)

    Hello,

    The cynexz solution doesn’t do the same thing.
    He retrieve all picture which have been uploaded by the current post.

    But in my plugin, images are not always attached to the post.

    I prefer this :

    foreach(get_images_src() as $k => $i){
    echo '<img src="'.$i[0].'" width="'.$i[1].'" height="'.$i[2].'" />';
    }

    ??

    Could you please give a sample for get_multi_images_src() please!

    Plugin Author Willy Bahuaud

    (@willybahuaud)

    Yes, no problem ??

    foreach(get_multi_images_src( 'thumbnail', 'large' ) as $k => $i){
    echo '<a href="'.$i[1][0].'" title="large size image"><img src="'.$i[0][0].'" width="'.$i[0][1].'" height="'.$i[0][2].'" /></a>';
    }

    You can also pass some parameter to the function, to include post thumbnail, or retrieve images of a specific post.

    thanks Willy

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Can't retrieve image on site’ is closed to new replies.