• Resolved Shekler

    (@shekler)


    Since the latest update (V1.2.3) image fields don’t show up as images anymore. Instead they are shown as raw text. Do I need to customize my block template and change it into an IMG tag? It worked without a dedicated IMG tag before and has been very comfortable.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @shekler,
    That must be frustrating.

    Did the block have the full <img> tag in the <input> before, not only the URL? Like:

    https://cldup.com/Z0HfocGkQs.png

    If so, the latest version, 1.2.3, won’t support that. Sorry, I hadn’t thought about that when I made the change. If that’s the case, yes, I’d recommend adding the <img> tag to the block template.

    • This reply was modified 5 years, 10 months ago by Ryan Kienstra.
    Thread Starter Shekler

    (@shekler)

    Yes, I think it had that before. I just had to pick the image from the library and the output was an image on the website. I didn’t have to include an img tag into the block template. Now, I have to upload the image and put the block_field into the src which is a problem as empty fields will still give out the img tag and therefore an empty code part on the website.

    Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @shekler,
    Sorry about that. I didn’t think about how the image field <input> could also be used for the full <img>.

    Now, I have to upload the image and put the block_field into the src which is a problem as empty fields will still give out the img tag and therefore an empty code part on the website.

    One thing you could do is something like:

    
    $src = block_value( 'foo-image' );
    if ( $src ) :
            ?>
            <img src="<?php echo esc_attr( $src ); ?>">
    <?php 
    endif;
    

    Of course, this is more complex than before.

    • This reply was modified 5 years, 10 months ago by Ryan Kienstra.
    Thread Starter Shekler

    (@shekler)

    Hey @ryankienstra,

    I was able to fix the output by doing something similar you suggested:

    <?php if (block_value('image')): ?>
        <img src="<?php block_field('image') ?>">
    <?php endif; ?>

    As I have several of these “image-blocks-parts” in a row, I didn’t define a variable.

    Thanks for the quick help.

    • This reply was modified 5 years, 10 months ago by Shekler.
    Plugin Author Ryan Kienstra

    (@ryankienstra)

    Hi @shekler,
    Thanks, that’s good to hear. Sorry for the breaking change.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Block Field Image outputs raw text instead of image’ is closed to new replies.