Support

Account

Home Forums Front-end Issues Image not showing correctly

Image not showing correctly

  • hello,

    i have a similar problem with Ie 8 and the field image.
    With the comptability ie 7 on the browser ie 8, it’s ok the picture are visibly, but only with ie 8 there ‘s no picture.

    i use this :
    <?php $image = wp_get_attachment_image_src(get_field(‘image_bloc_2’), ‘medium-3’); ?>
    ” alt=”<?php echo get_the_title(get_field(‘image_bloc_2’)) ?>” />

    When i use the url and not the id, i can’t use the size of the image.

    you can see it here: http://www.vertikaro.com

    with firefox, safari chrome, it’s ok,

    can you help me ?

  • Hi @micromaniac

    I have split this comment into it’s own topic as it was very different to the original.

    To get a specific ‘size’ for an image, you MUST use either ID or Array as the return type. I can’t explain why it is working for you in firefox + URL, but I can only hope it is a caching issue.

    Please use either ID or Array as instructed in the documentation.

    Thanks
    E

  • Hello Elliot,

    When i use the id, the problem is with Internet explorer 8, the picture are not showing.

    you have a solution ?

    best

    Benoit

  • Hi @micromaniac

    Because PHP runs on the server and is not browser dependent, the issue cannot be related to a browser.

    The fact that it works on ie, and not firefox is down to something else. Perhaps some JS running on the page or some caching going on.

    Lets fix your code logically. First, lets debug the value returned by get_field. You can do this by:

    
    <?php 
    
    echo '<pre>';
    	print_r( get_field('image_bloc_2') );
    echo '</pre>';
    die; 
    
    ?>
    

    What do you get from that?

    Next is to debug the returned value from the wp_get_attachment_image_src function.
    What do you get for that?

    You can find docs on that function here:
    http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

    Please note that this function returns an array and the src is actually at $image[0]. This means that your code won’t work because you are trying to echo an array.

    Please read over the image field documentation to get a better understanding of how to use this function.

    Thanks
    E

  • hello Elliot,

    when i try this:
    <?php

    echo ‘

    ';
    	print_r( get_field('image_bloc_2') );
    echo '

    ‘;
    die;

    ?>

    the slider and the page content are not showing,
    you can see on the png,

    best

  • Hi @micromaniac

    The ‘die’ command will prevent the rest of the page from loading. This is so you can then inspect the DOM / HTML source and see the debug info clearly (last HTML on page)

    What is inside the <pre></pre> tags in the source code?

    Thanks
    E

  • hello Elliot,

    inside

    
    <?php 
    
    echo '
    ';
    	print_r( get_field('image_bloc_2') );
    echo '

    ';
    die;

    ?>

  • Hi @micromaniac

    The code you pasted above is the PHP code which you are using to debug.
    Can you please view the source of the page and find the pre tags in the HTML? What is within the pre tags?

    Thanks
    E

    Please wrap any code within the ‘code’ button tags when commenting.

  • hello Elliot,

    sorry,

    in the pre tag i have : 260

    best,

  • Hi @micromaniac

    Thanks for the info. We can confirm that the get_field function is returning the correct data.

    In a previous comment, I mentioned that the function you are using “wp_get_attachment_image_src” returns an array of data, not just a string. Have you taken this into consideration with your code and output the src like so:

    
    <?php
    
    $image = wp_get_attachment_image_src(get_field('image_bloc_2'), 'medium-3');
    
    ?>
    <img src="<?php echo $image[0]; ?>" />
    

    Thanks
    E

  • hello Elliot,

    yes it’s like this !

    but the picture are not showing with ie 8.

    best

    benoit

  • Hi @micromaniac

    This could be a security issue or even a HTML validation issue.
    It sounds like ACF is working correctly with your code, so we can mark this as solved.

    Good luck with your ie issue.

    Thanks
    E

Viewing 12 posts - 1 through 12 (of 12 total)

The topic ‘Image not showing correctly’ is closed to new replies.