Title: Get image form variable
Last modified: August 24, 2016

---

# Get image form variable

 *  [adminbart](https://wordpress.org/support/users/adminbart/)
 * (@adminbart)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/)
 * Hello,
 * I’ve got a ‘rent product’ link by each product shown on a page.
    The link passes
   a php variable, e.g: [http://www.webdesignbart.be/?urlProduct=http://www.webdesignbart.be/joca/wp-content/uploads/2015/03/summer-winter-256701.jpg](http://www.webdesignbart.be/?urlProduct=http://www.webdesignbart.be/joca/wp-content/uploads/2015/03/summer-winter-256701.jpg)
 * I want to get the image URL in the form, and in the e-mail posted to the admin
   and user.
 * In php I would use this:
 *     ```
       <?php
       if (isset($_GET['urlProduct'])) {
           echo $_GET['urlProduct'];
       }else{
           // Fallback behaviour goes here
       }
       ```
   
 * But I can’t use php in the form.
    I’ve been looking for hours for this to work,
   so …
 * Can anyone help me out? I would be very greatfull!
 * Kind regards,
    Bart
 * [https://wordpress.org/plugins/ninja-forms/](https://wordpress.org/plugins/ninja-forms/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [respectyoda](https://wordpress.org/support/users/respectyoda/)
 * (@respectyoda)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004039)
 * Hello! Thank you for using Ninja Forms. You can use a hook to modify the default
   value of any field in which you can use PHP.
 *  Thread Starter [adminbart](https://wordpress.org/support/users/adminbart/)
 * (@adminbart)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004048)
 * Thank you for your reply!
 * Perhaps I don’t undestrand your answer, but I don’t need it to be in a field,
   it just needs to be shown somewhere in the form and in the emails (admin and 
   user).
 * But perhaps I need to modify a field as you say, can you help me on how to do
   that?
    I’m a designer, not a developer, so this may sound a stupid question 🙂
 * Kind regards, Bart
 *  [respectyoda](https://wordpress.org/support/users/respectyoda/)
 * (@respectyoda)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004049)
 * You can use a field, but set it to be readonly so it cannot be modified by the
   user and this will show up on the front end and in the emails.
 * You can use this [hook](http://docs.ninjaforms.com/article/146-ninjaformsfield)
   to modify the default value of the field.
 * Do you want to use the image URL or the product page’s URL?
 *  Thread Starter [adminbart](https://wordpress.org/support/users/adminbart/)
 * (@adminbart)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004050)
 * Thanks for the fast answer. I will check your link over an hour from now.
 * I want to use the image url, because there are more than one item on a page.
 *  [respectyoda](https://wordpress.org/support/users/respectyoda/)
 * (@respectyoda)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004051)
 * You are welcome. Ah I understand. All right. If you need any further help, just
   let me know! 🙂
 *  Thread Starter [adminbart](https://wordpress.org/support/users/adminbart/)
 * (@adminbart)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004065)
 * Hello Respectyoda,
 * I can’t seem to get it right 🙁
    But as I mentioned: I’m not a developer.
 * How can I set a field to readonly?
    How can I retrieve the fields ID?
 * Is it the main functions.php-file of the theme where I add this?
 *     ```
       <?php
        // instead of the URL I want an image
       $url = '<img src="'. $_GET["foto"] . '">';
   
       function my_filter_function( $data, $field_id ){
         if( $field_id == 3 ){$data['default_value'] = $url;}
         return $data;
       }
       add_filter( 'ninja_forms_field', 'my_filter_function', 10, 2 );
       ```
   
 * Should the code look like this?
 * I hope I’m not asking too much of your time 🙁
 * Kind regards,
    Bart
 *  [respectyoda](https://wordpress.org/support/users/respectyoda/)
 * (@respectyoda)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004077)
 * Yes, it is the functions.php file the code must be in.
 * If you want the textbox to be readonly then go to the particular form in the 
   backend -> Restriction Settings -> Disable input (make sure this box is checked).
 * As for the field’s ID, once again, go to the particular form in the backend and
   open the field to show information about the field. There you should find the
   field ID.
 * As for the code, you really don’t need the img tags, just the URL.
 *     ```
       function my_filter_function( $data, $field_id ){
         if ( $field_id == 3 ){
           $data['default_value'] = $_GET["foto"];
         }
         return $data;
       }
       add_filter( 'ninja_forms_field', 'my_filter_function', 10, 2 );
       ```
   
 *  Thread Starter [adminbart](https://wordpress.org/support/users/adminbart/)
 * (@adminbart)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004091)
 * Great! You’re a genius! Thanks!!!
 * But because I’m using a texfield I see a field with the URL in it, but not an
   image. Perhaps there’s a way to show the image?
 *  [respectyoda](https://wordpress.org/support/users/respectyoda/)
 * (@respectyoda)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004117)
 * You are welcome!
 * So you want to show the image of the product in the email?
 *  Thread Starter [adminbart](https://wordpress.org/support/users/adminbart/)
 * (@adminbart)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004119)
 * Goodmorning respectyoda, thats wright, I would like to show the image.
    If it
   possible 🙂
 * Have a nice day!
    Bart

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Get image form variable’ is closed to new replies.

 * ![](https://ps.w.org/ninja-forms/assets/icon-256x256.png?rev=1649747)
 * [Ninja Forms - The Contact Form Builder That Grows With You](https://wordpress.org/plugins/ninja-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ninja-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ninja-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/ninja-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ninja-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ninja-forms/reviews/)

## Tags

 * [forms](https://wordpress.org/support/topic-tag/forms/)
 * [get](https://wordpress.org/support/topic-tag/get/)
 * [pass variable](https://wordpress.org/support/topic-tag/pass-variable/)

 * 10 replies
 * 2 participants
 * Last reply from: [adminbart](https://wordpress.org/support/users/adminbart/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/get-image-form-variable/#post-6004119)
 * Status: not resolved