Using theme_image_style() I am trying to display thumbnails of uploaded images in a custom form. While I can see the images in my form array after uploading them to the tmp directory in Drupal, here is what I am trying to use to display them:

$url = file_create_url($form_object-&gt;uploads[$key]-&gt;uri);
$output .= '&lt;div class="grid-3"&gt;'.theme_image_style(array('style' =&gt; 'form-preview', 'path' =&gt; $url)).'&lt;/div&gt;';


While $url points to the file resource, I cannot show a resized image for the life of me. If I use an img tag and put $url as its source, the images do show up, but they are huge.

Can I not call theme_image_style() because these are just temp images and not permanent? I can make them appear with theme_image().
As always, the Drupal documentation has the answer. You need to move the file to the files directory. Also you should never call a theme function directly but instead call the wrapper theme function so:

theme_image_style(...) // Don't do this ever

theme('image_style', ...) // Do it like this and make themers happy.


From the API docs:


  $variables An associative array containing:
  
  
  style_name: The name of the style to be used to alter the original image.
  path: The path of the image file relative to the Drupal files directory. This function does not work with images outside the files directory nor with remotely hosted images.
  alt: The alternative text for text-based browsers.
  title: The title text is displayed when the image is hovered in some popular browsers.
  attributes: Associative array of attributes to be placed in the img tag.