Getting The URL of an Uploaded Image
-
Hi Guys,
Adam helped me out to show the latest submitted form into a shortcode on another thread (https://www.ads-software.com/support/topic/showing-a-single-field-of-the-latest-entry-using-a-shortcode/#post-17554253)Now, what I’m trying to do is showing an image using the same kind of shortcode, but I’m having a trouble to achieve that.
I added an Image upload field, I tried the code Adam gave me on the other thread and refer it to the Image-1 field. But it doesn’t work. I tried to var_dump(?) the data: it says like this:["upload-1"]=> array(2) { ["id"]=> string(3) "307" ["value"]=> array(1) { ["file"]=> array(5) { ["success"]=> bool(true) ["file_name"]=> string(63) "image.jpg" ["file_url"]=> string(173) "https://websitename/filepath/to/image.jpg" ["message"]=> string(0) "" ["file_path"]=> string(175) "filepath/to/the/hosting/image.jpg" } } }
Now, I want to get the URL on that Array, the [“file_url”]=> string(173) “https://websitename/filepath/to/image.jpg” section
The code Adam gave me that I modified is like this (it doesn’t work, only gave me a result of “value”):
add_shortcode( 'image1-last-entry', 'wpmu_shortcode_forminator_last_entry_field_image1' ); function wpmu_shortcode_forminator_last_entry_field_image1( $atts ) { $a = shortcode_atts( array( 'form_id' => 7266, 'field' => 'upload-1', ), $atts ); $entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $a['form_id'] ); if ($entry) { //this is where i think i did wrong $html = $entry->meta_data[$a['field']][['value']['file']]; if ($html) { return $html; } }
Now, my question is: how do i get the value of “file_url” inside the array inside array(?). I just need the return value of “https://websitename/filepath/to/image.jpg”
It might seem trivial for the other programmers but it keep bugging me out for a few days now.
thank you very much!
- The topic ‘Getting The URL of an Uploaded Image’ is closed to new replies.