anchor.diff:                  _ ->
                       []
               end,
  -    ContextUpload = handle_media_upload(EventProps, Context,
  -                                        %% insert fun
  -                                        fun(Ctx) -> m_media:insert_url(Url, Props, Ctx) end,
  -                                        %% replace fun
  -                                        fun(Id, Ctx) -> m_media:replace_url(Url, Id, Props, Ctx) end),
  -
  -    %% Close the dialog and optionally perform the post upload actions
  -    z_render:wire({dialog_close, []}, ContextUpload).
  +    handle_media_upload(EventProps, Context,
  +                        %% insert fun
  +                        fun(Ctx) -> m_media:insert_url(Url, Props, Ctx) end,
  +                        %% replace fun
  +                        fun(Id, Ctx) -> m_media:replace_url(Url, Id, Props, Ctx) end).
   
   
   
  
positive.code:                             end,
                      Actions2 = [add_arg_to_action({id, MediaId}, A) || A <- Actions],
                      z_render:wire([
                              {growl, [{text, "Uploaded the file."}]},
                              {dialog_close, []} 
                              | Actions2], ContextRedirect);
                  {error, _Error} ->
                      z_render:growl_error("Error uploading the file.", Context)
              end;
        
          %% Replace attached medium with the uploaded file (skip any edge requests)
          N when is_integer(N) -> 
              case ReplaceFun(Id, Context) of
                  {ok, _} ->
                      Context1 = z_render:wire(Actions, Context),
                              z_render:growl("Uploaded the file.", Context1);
                  {error, eacces} ->
                              z_render:growl_error("You don't have permission to change this page.", Context);
                  {error, _} ->
                      z_render:growl_error("Error uploading the file.", Context)
              end
      end.
  
  
  % Add an extra argument to a postback / submit action.
  add_arg_to_action(Arg, {postback, [{postback, {Action, ArgList}} | Rest]}) ->
  
negative.code: 
  event(#submit{message={media_upload, EventProps}}, Context) ->
      File = z_context:get_q_validated("upload_file", Context),
      case File of
          #upload{filename=OriginalFilename, tmpfile=TmpFile} ->
              Props = case proplists:get_value(id, EventProps) of
                          undefined ->
                              Lang = z_context:language(Context),
                              Title = z_context:get_q("new_media_title", Context),
                              NewTitle = case z_utils:is_empty(Title) of
                                             true -> OriginalFilename;
                                             false -> Title
                                         end,
                              [{title, {trans, [{Lang,NewTitle}]}},
                               {language, [Lang]},
                               {original_filename, OriginalFilename}];
                          _ ->
                              [{original_filename, OriginalFilename}]
                      end,
              handle_media_upload(EventProps, Context,
                                  %% insert fun
                                  fun(Ctx) -> m_media:insert_file(TmpFile, Props, Ctx) end,
                                  %% replace fun
                                  fun(Id, Ctx) -> m_media:replace_file(TmpFile, Id, Props, Ctx) end);
          _ ->
              z_render:growl("No file specified.", Context)
      end;
  
  event(#submit{message={media_url, EventProps}}, Context) ->
      Url = z_context:get_q("url", Context),
  