• I am using wordpress acf plugin to show

    some custom images with their description and some text

    .So I just installed the plugin and just made the acf plugin fileds with their requirment. I am using returning value as

    image object

    just to get some extra fields like description, some text, the image. I also assigned the page to the home page with the

    conditional tags Location-> Rules-> Page->is equal to-> Home

    now when I made my content-page.php to show the image code like this

    <?php
    if( get_field('image') ):
        ?><img src="<?php the_field('image'); ?>" alt="" /><?php
    endif;
    ?>

    I am getting only a broken image. The firebug is showing image source like this

    <img src="16, , 527060_409581309078088_1132701086_n, , , https://localhost/Tryouts/WordPress/wp-content/uploads/2013/02/527060_409581309078088_1132701086_n.jpg, 850, 315, Array" alt="">

    Kindly help me to solve this. I have already wasted one day behind it. So any help and suggestions will be really appreciable. Thanks

Viewing 1 replies (of 1 total)
  • writecraft

    (@writecraft)

    Looks like ACF uses an array now for their image fields, but haven’t updated their documentation. Put the array into a variable, then get the image url or id from the array, like this:

    <?php
    if (get_field('image_field')) {
    // put the field array into a variable
    $imgarray = get_field( 'image_field' );
    ?>
    // then extract the image url from the array
    <img src="<?php echo $imgarray['url'] ; ?>" alt=""/>
    <?php } //end if ?>

    or this, to get a particular size:

    <?php
    if (get_field('image_field')) {
    // put the field array into a variable
    $imgarray = get_field( 'image_field' );
    // then extract the image id
    $size = "thumbnail"; // (thumbnail, medium, large, full or custom size)
    echo wp_get_attachment_image( $imgarray['id'], $size );
    } //end if
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘advanced custom plugin showing broken image’ is closed to new replies.