SOLVED: ACF image query broken print

Bricks Version: 1.5

Hi!
I made to my Woocommerce attributes a color picker and an image upload.
I want to use the image upload option to th “brand” attribute, and print the brand’s logo to the page. (example single product page.)

But when i want print it, the image is broken? The allowed image type is svg
What i make wrong? Or is it a bug?

Hey,
Thank you very much for your report!

Can you provide a live link so that I can look at the code?

Best regards,
timmse

1 Like

Yes of course. But it is sensitive, how can I send you it with no public format?

@simplecreative You can DM them or send via the contact form here. Contact – Bricks (bricksbuilder.io)

Thanks, i sent the message.

Hi Patrik,
in general I can say that this is not a Bricks problem :slight_smile:

  1. Your ACF fields are assigned to taxonomies (tags), which you want to output in the Single Product. This is not so easy, because posts and taxonomies are two different objects.
  2. the dynamic data tag you used was wrong because you queried the terms but not the ACF field.

On the fly, this seems to work: I loop through the tags and check if the ACF field contains data. If so, I output it directly to an image tag.

<?php

  $terms = wp_get_object_terms(get_the_ID(), 'product_tag');
  if(!empty($terms)){
    foreach($terms as $term){
      $tag_img = get_field('attribute_img', $term);
      if($tag_img) {
	      echo '<img src="'.$tag_img.'" width="140" height="auto" />';
    }
   }
  }
  
?>

See: Panasonic / Gree

Best regards,
timmse

Thanks your work and support Timmse!

I was hoping that calling in dynamic content would work in the same way as with JetEngine and that there would be no need to fiddle with individual php code.

The strange thing about your solution is that the logo does not appear for certain products (eg the Fisher brand), even though the brand logo is uploaded among the attributes.

Hey,
I don’t know where you added the Fisher Logo, but the ACF Image for the “Fisher” Tag is empty :wink:

Ohhh! It is very very wierd!
I made it about 10 minutes ago before you made screenshot!

I dont know why aren’t you see it. :smiley:

You are editing the Attributes, I’m editing the tags :wink: Take a look at my screenshot. That’s why I highlighted the menu :sunglasses:

Theoretically, you can modify the PHP code to query the attributes instead of the tags.

1 Like

Ohhhh! Sorry! I didnt see it.
Thank you very much.

It was not by chance that I wanted to add it as a product attribute.
1.) It would be possible use in filters (not text but with brand logo appearance)
3.) It can also be turned into an Archive page, linkable.
Used as a tag, it’s just visual eye candy. :frowning:

I have seen such a solution on several ready-made templates, that you can use a color picker and image upload next to the product attribute, and then call them instead of the text.

I have already done this myself with the Elementor JetEngine combo, and a similar method was able to call an image instead of text, without any unique php coding.

I was confident that this kind of no-coding visual representation would also work under Bricks Builder. :frowning:

Regardless, I am grateful for your efforts and work. I already looked for a solution for this, but unfortunately it doesn’t exist under Bricks Builder. I just was hoping that this really wonderful builder would know such a “basic” thing.

Ok, somehow we talked past each other. Querying the pa_marka term is even easier:

<?php

  $tax = get_the_terms( get_the_ID(), 'pa_marka' );
  $brand_img = get_field('attribute_img', $tax[0]);

  if($brand_img) {
	echo '<img src="'.$brand_img.'" width="140" height="auto" />';  
  }

?>

Best regards,
timmse

Is it working?
I can’t call the taxonomy’s custom field image in a. archive or singe teplate

Using Bricks 1.5.4

Yes it working to me, but not to smart. Can’t link, just print one image.
Put the code into a code widget and change in the code the necessary items. (example pa_marka it is my brand attribute name…)