anchor.diff:      encodings_provided/2,
       provide_content/2,
       finish_request/2
  -]).
  +        ]).
   
   -include_lib("webmachine_resource.hrl").
   -include_lib("zotonic.hrl").
  
positive.code:     false;
  file_exists(Name, Context) ->
      RelName = case hd(Name) of
          $/ -> tl(Name);
          _ -> Name
      end,
      case mochiweb_util:safe_relative_path(RelName) of
          undefined -> false;
          SafePath ->
              RelName = case hd(SafePath) of
                  "/" -> tl(SafePath);
                  _ -> SafePath
              end,
              Root = case z_context:get(root, Context) of
                  undefined -> 
                      case z_context:get(is_media_preview, Context, false) of
                          true  -> [z_path:media_preview(Context)];
                          false -> [z_path:media_archive(Context)]
                      end;
                  ConfRoot -> ConfRoot
              end,
              file_exists1(Root, RelName, Context)
      end.
  
  
negative.code:             {false, ReqData, Context};
          Safepath  ->
              MediaPath = case z_context:get(media_path, Context) of
                              undefined -> z_path:media_archive(Context);
                              ConfMediaPath -> ConfMediaPath
                          end,
              
              MediaFile = case Safepath of 
                              "lib/" ++ LibPath ->  
                                  case z_module_indexer:find(lib, LibPath, Context) of 
                                      {ok, ModuleFilename} -> ModuleFilename; 
                                      {error, _} -> filename:join(MediaPath, Safepath) 
                                  end; 
                              _ -> 
                                  filename:join(MediaPath, Safepath) 
                          end,
              case filelib:is_regular(MediaFile) of
                  true ->
                      % Media file exists, perform the resize
                      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 -> {true, ReqData, z_context:set(fullpath, PreviewFile, Context)};
  