I'm theming the email that a webform submission generates, and I want to create fqdn'd links to the images that the submitter has uploaded.

I used [submission:values:photo:nolabel], but that generates a url which links to http://sites/default/files/webform/index1_7.jpg. Obviously that URL is broken. Because it's a token string, I can't manipulate it with php string manipulation functions, to take off the http:// part.

The same thing happens with [submission:values:photo_2].

I want to get just the path part, so that I can construct a proper link. I've looked in "Available Tokens" under the webform configuration, but that just lists what I've already tried.

What token gives me just the path to the image on the site?


It turns out that there is some later template processing, or perhaps an email client display issue, that is causing my links to be displayed as relative paths.

However, in arriving to this conclusion, I was able to construct the URL from the submitted values.

First, get the ids of the webform components that are uploaded files. These are in the $submission->data array.

Then, load each like so:

foreach ( $fids as $fid ) {
    $file = file_load($fid);
    $url = file_create_url($file->uri);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.