0

I'm using the Simple Fields plugin (http://wordpress.org/plugins/simple-fields/) and am having the hardest time creating a slideshow from a repeatable field group. I've tried piecing everything that I could find from the documentation and from others who have had similar issues, but everything I try results in an "invalid argument" or no image src returned.

This code is working, but I need to know how to tell it to display the 'large' size image:

<ul class="slides">
    <?php
        $slideshow_repeat = simple_fields_get_post_group_values(get_the_id(),"Slideshow", true, 2);
            foreach ( $slideshow_repeat as $slide ) {
                $image_src = wp_get_attachment_image_src($slide['Slide']);
    ?>
    <li>
        <img src="<?php echo $image_src[0]; ?>" alt="<?php echo $slide['Title']; ?>"/>
        <h2><?php echo $slide['Title']; ?></h2>
        <p><?php echo $slide['Caption']; ?></p>
        <p><?php echo $slide['Image Credit']; ?></p>
    </li>

    <?php
        }
    ?>
</ul>

If anyone can help, I'd really appreciate it.

1
  • Please always add links to plugins or themes in question. – kaiser Nov 5 '13 at 3:15
1

You're calling wp_get_attachment_image_src() without further arguments. The second argument is the size and it defaults to thumbnail. See source:

wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false )
2
  • Thanks for the tip, kaiser—link added. I'm still having trouble. Fleshing out the arguments results in no image src being sent through. Any other suggestions? – robalan Nov 5 '13 at 4:38
  • Please enable debugging - blueprint for wp-config.php - and file an edit so we can look at your error messages. Next thing: Which size do you call? Is it registered and if yes: Where? – kaiser Nov 5 '13 at 13:55
0

Finally was able to ask a friend to help me get this to work in person. Here's what we changed:

<ul class="slides">
    <?php
    $slideshow_repeat = simple_fields_get_post_group_values( get_the_id(), "Slideshow", true, 2 );
    print_r( $slideshow_repeat );
    foreach ( $slideshow_repeat as $slide ) {
        // This is the important bit
        $image_src = wp_get_attachment_image_src( $slide['Slide'], 'full' );
        ?>
        <li>
            <img src="<?php echo $image_src[0]; ?>" alt="<?php echo $slide['Title']; ?>"/>
            <h2><?php echo $slide['Title']; ?></h2>
            <p><?php echo $slide['Caption']; ?></p>
            <p><?php echo $slide['Image Credit']; ?></p>
        </li>

        <?php
    } ?>
</ul>

$slide['Slide'] was returning the attachment ID, so we didn't need to go any deeper in the array to assign the size. Hope that makes sense!

2
  • Basically you're now adding the second argument full, right? ;) btw, if you want to highlight code parts, please use comments instead of breaking it. – kaiser Nov 7 '13 at 8:04
  • Yes, absolutely. :) I just didn't know format it properly, apparently. Thanks for your help. – robalan Nov 7 '13 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.