anchor.diff:              case filelib:is_regular(MediaFile) of
                   true ->
                       % Media file exists, perform the resize
  -                    Root = case State#state.root of
  +                    Root = case z_context:get(root, Context) of
                           [ConfRoot|_] -> ConfRoot;
                           _ -> z_path:media_preview(Context)
                       end,
                       PreviewFile = filename:join(Root, Path),
                       case z_media_preview:convert(MediaFile, PreviewFile, PreviewPropList, Context) of
  -                        ok -> resource_exists(ReqData, State);
  +                        ok -> {true, ReqData, z_context:set(fullpath, PreviewFile, Context)};
                           {error, Reason} -> throw(Reason)
                       end;
                   false ->
  -                    {false, ReqData, State}
  +                    {false, ReqData, Context}
               end
       end.
  -
   
   
   %% Encode the data so that the identity variant comes first and then the gzip'ed variant
  
positive.code: %% @author Marc Worrell <marc@worrell.nl>
  %% @copyright 2009 Marc Worrell
  %%
  %% @doc Serve static (image) files from a configured list of directories or template lookup keys.  Caches files in the local depcache.
  %% Is also able to generate previews (if configured to do so).
  
  %% Copyright 2009 Marc Worrell
  %%
  %% Licensed under the Apache License, Version 2.0 (the "License");
  %% you may not use this file except in compliance with the License.
  
negative.code: is_text(_Mime) -> false.
  
  
  %% @spec ensure_preview(ReqData, Path, Context) -> {Boolean, NewReqData, NewContext}
  %% @doc Generate the file on the path from an archived media file.
  %% The path is like: 2007/03/31/wedding.jpg(300x300)(crop-center)(709a-a3ab6605e5c8ce801ac77eb76289ac12).jpg
  %% The original media should be in State#media_path (or z_path:media_archive)
  %% The generated image should be created in State#root (or z_path:media_preview)
  ensure_preview(ReqData, Path, Context) ->
      {Filepath, PreviewPropList, _Checksum, _ChecksumBaseString} = z_media_tag:url2props(Path, Context),
      case mochiweb_util:safe_relative_path(Filepath) of
          undefined ->
              {false, ReqData, Context};
          Safepath  ->
              MediaPath = case z_context:get(media_path, Context) of
                  undefined -> z_path:media_archive(Context);
                  ConfMediaPath -> ConfMediaPath
              end,
  