WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Calling image from pod field

[Resolved] Calling image from pod field

  • Follow up to my previous post, this time to call an image from a pod field.

    Using <?php echo get_post_meta( 56, 'photo', true ); ?> (where ‘photo’ is the field in my pod where I upload an image) does not display the image. It just displays the word “Array” where the image should be. I would like to know why this is and how to rectify. Any help really appreciated.

    Ideally I would like to display the image as a background image, I guess by putting an inline css rule.

    Here’s my code so far: http://pastebin.com/RkZ6hRg5

    http://wordpress.org/extend/plugins/pods/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Scott Kingsley Clark

    @sc0ttkclark

    get_post_meta( 56, 'photo', true ) will return an a array of the file information. Try this instead:

    <?php echo pods_image( get_post_meta( 56, 'photo', true ), 'thumbnail' ); ?>

    You can customize ‘thumbnail’ to be whatever size of the image you want it to be.

    Thanks Scott! That’s displays the image perfectly.

    Just one thing though, I’m trying to get it to load as a background image to a div (“featuredwork”). But my level of php currently fails me. I’ve tried:

    <div class="featuredwork" style="background:url('<?php echo get_post_meta($post->ID, 'main_photo', true); ?>');>

    As well as declaring the variable $bg:
    <?php $bg = wp_get_attachment_image_src(get_post_meta($post_id, 'main_photo', true ), 'original');?>
    and calling it as so:
    <div class="featuredwork" style="background:url('<?php echo $bg?>');">

    But neither works. Any pointers?

    Plugin Author Scott Kingsley Clark

    @sc0ttkclark

    Output an image:

    echo pods_image( get_post_meta( 56, 'photo', true ), 'original' );

    Output an image’s URL:

    echo pods_image_url( get_post_meta( 56, 'photo', true ), 'original' );

    So for your needs:

    $bg = pods_image_url( get_post_meta( 56, 'photo', true ), 'original' );

    perfect. can i buy you a beer ? do you have a donations link?

    Plugin Author Scott Kingsley Clark

    @sc0ttkclark

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Calling image from pod field’ is closed to new replies.