Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

How to display image?

Open GreenLightSM opened this issue 8 years ago • 7 comments

Hi, i have a field in customizer with "upload" type. I want to display the image in header, but i have an error - "Notice: Array to string conversion in D:\OSPanel\domains\ardis-creative-agency\wp-content\themes\ardis\header.php on line 82 Array". This is how i try to display it - ";". Thank you!

GreenLightSM avatar Jun 11 '18 15:06 GreenLightSM

The image uploader outputs an array with key attachment_id and url. Perhaps you echoed it wrong. So instead of $atts['image'], it should be $atts['image']['url'].

jonmlas avatar Jun 11 '18 16:06 jonmlas

@jonmlas Thank you!

GreenLightSM avatar Jun 11 '18 19:06 GreenLightSM

@jonmlas I have an error when i'm trying to do like this:

$header_image = fw_get_db_customizer_option('image_header'); echo $header_image['image']['url'];

And error is:

Notice: Undefined index: image in D:\OSPanel\domains\ardis-creative-agency\wp-content\themes\ardis\header.php on line 84

GreenLightSM avatar Jun 13 '18 13:06 GreenLightSM

Could you try to check the value of $header_image?

You can do that by using fw_print($header_image);

Let me know the value.

jonmlas avatar Jun 13 '18 13:06 jonmlas

@jonmlas array ( [attachment_id] => '43' [url] => '//ardis-creative-agency/wp-content/uploads/2018/06/Illustration.png' )

GreenLightSM avatar Jun 13 '18 13:06 GreenLightSM

then, you should echo $header_image['url']; not echo $header_image['image']['url'];

jonmlas avatar Jun 13 '18 13:06 jonmlas

@jonmlas Oh, it works, finally:) Thank you so much! I almost died solving this:)

GreenLightSM avatar Jun 13 '18 14:06 GreenLightSM