Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
99 views
in Technique[技术] by (71.8m points)

php - How to show uploaded image in frontend vendor dashboard?

I'm try to show vendor uploaded QR code in vendor dashboard.(Check screenshot 1)

Screenshot 1

screenshot 1


Source Code

 add_action( 'dokan_dashboard_right_widgets', array( $this, 'get_qr_code_widget' ), 10 );

 public function get_qr_code_widget() {
   if ( ! current_user_can( 'dokan_view_sales_report_chart' ) ) 
{
            $new_qr= get_field( 'new_qr', 'Vendor');
            $Image3_URL=wp_get_attachment_url($new_qr);
            return;
        }

        echo '<img src=" '.$Image3_URL.'" width="200" height="200" alt="Lanka QR" ';
}

This is my advance custom field details.(Please Check screen shot 2, 3 & 4)

screenshot 2 screenshot 2

screenshot 3 screenshot 3

screenshot 4 screenshot 4

WordPress vendor form details.(Please Check screen shot 5)

screenshot 5

I tried so many codes but nothing work, if anyone can help me really appreciate it.

question from:https://stackoverflow.com/questions/65883268/how-to-show-uploaded-image-in-frontend-vendor-dashboard

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The wp_get_attachment_url() function parameter must be the attachment id, as you can see here:

https://developer.wordpress.org/reference/functions/wp_get_attachment_url/

The line

$new_qr= get_field( 'new_qr', 'Vendor');

returns the ID?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...