PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Show uploaded image (or get location) before submission (instead of link)

  1. Hi,

    I searched a lot, but couldn't seem to find an answer to what I think is a very simple problem.

    On my confirmation page (using 'better pre-submission-confirmation) I want to show the image that was uploaded a couple of steps earlier.

    When I use the merge tag {File:1} it creates automatically a link, therefore <img src="{File:1}" /> obviously does not work.

    Thanks,

    Tom

    Posted 11 years ago on Thursday November 15, 2012 | Permalink
  2. Anyone? :)

    Posted 11 years ago on Friday November 16, 2012 | Permalink
  3. David Peralty

    Can you please try {File:1:url} and let me know if that produces the result you want?

    Posted 11 years ago on Friday November 16, 2012 | Permalink
  4. Hi David,

    Thanks for your respond.
    When I do that, it also exactly the same I am afraid.

    Thanks,

    Tom

    Posted 11 years ago on Friday November 16, 2012 | Permalink
  5. David Peralty

    I've asked a developer to weigh in on why this isn't working for you.

    Posted 11 years ago on Friday November 16, 2012 | Permalink
  6. Thank you so much!

    Posted 11 years ago on Friday November 16, 2012 | Permalink
  7. matsilva
    Member

    Hey Tom....I have worked on this prior and instead of using

    {File:1}
    use
    {:1} or whatever the upload field was set to inside of a HTML field

    Next the default display of the uploaded file doesn't display as a direct url but rather a link.

    Since you are using David Smiths snippet over here http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/

    modify this portion

    $file_path = $value;
            if(!empty($file_path)){
                $file_path = esc_attr(str_replace(" ", "%20", $file_path));
                $value = "<a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $file_info['uploaded_filename'] . "</a>";
            }
            return $value;

    to this

    $file_path = $value;
            if(!empty($file_path)){
                $file_path = esc_attr(str_replace(" ", "%20", $file_path));
                $value = "<img src='$file_path' alt='' width='200' />";
            }
            return $value;

    This changes it from a link to a img src reference instead. I added my own width value for my own use but its a decent start if this is what you are looking to do.

    Hope that helps!

    Posted 11 years ago on Saturday November 17, 2012 | Permalink
  8. Hi Tom,

    Matt's solution will work for you. In the future, I plan to update my snippet to allow you to pass a ":raw" filter which will return the value unmodified.

    Posted 11 years ago on Saturday November 17, 2012 | Permalink
  9. Guys this works perfect!
    Thank you so much. My form looks much better now :)
    Cheers, Tom

    Posted 11 years ago on Monday November 19, 2012 | Permalink
  10. Thanks Tom.

    Posted 11 years ago on Monday November 19, 2012 | Permalink

This topic has been resolved and has been closed to new replies.