Support

Account

Home Forums Front-end Issues Problems with images in Link Text

Solving

Problems with images in Link Text

  • Hello acf community.
    First of all excuse my english.

    I’ve got a problem. I’m using the ACF linkfield (as array). Inside the linktext I use images/icons (inplmented by ). When I’m doing this the imgtag sometimes is rendered correctly and sometimes not. It’s seems just random if it works or not. I loaded some exmaples up.

    I don’t use esc_html($link.. and tried things out like strip_tags – nothing works. I have to say, I’m not a php pro. Andyone has an idea what I can do?

  • It appears that some of your code was removed. Please you code tags from the editor menu when posting code.

  • <?php if( $button_buy ): 
    	$button_buy_url = $button_buy['url'];
    	$button_buy_title = $button_buy['title'];
    	$button_buy_target = $button_buy['target'] ? $button_buy['target'] : '_self';
    ?>
    	<a class="button button-buy" href="<?php echo esc_url( $button_buy_url ); ?>" target="<?php echo esc_attr( $button_buy_target ); ?>"><?php echo strip_tags($button_buy_title); ?></a>
    <?php endif; ?>	

    Hey John, hope this helps. This ist the code from the template. I’m using normal img tag inside the Linktext. Can you see it in the picture i loaded up? I blacked out the URL for reasons.

  • I don’t understand where you are getting the image from, is this entered into the link text? If it is something is transforming the html. I don’t know what that is.

    try dumping the value and see if the HTML is altered before you add the link.

    
    echo '<pre>'; var_dump($button_buy); echo '</pre>';
    
  • Hey John. Sorry for my bad explanations.

    Yes. The image is postetd directly inside the linktext, see the picture i loaded up. I tested your script. The result you can also see in the uploaded images. The crazy about is, that sometimes it’s working and sometimes not. But I don’t want to waste your time too much. Otherwise I’ll find another soultion. Maybe I can add an acf imagefield and call it directly inside the linktag. So ->a,img,linktext,/a<- That would probably make more sense too.

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

You must be logged in to reply to this topic.