var
  i: Integer;
  VURL: String;
  VResponseHeader: AnsiString;
  VResponseData: AnsiString;
  VImgURL: String;
  VImgBIG: String;
  VEnabled: Boolean;
  VCaption: String;
  VUserNumber: String;
  VUserDescr: String;
begin
  VEnabled := MapAttachmentsInfo.GetEnabled(0);
  
  if (not VEnabled) then
  begin
    ResultText := SourceText;
    Exit;
  end;
  
  // check attachment in storage (loop through all items)
  if MapAttachmentsInfo.GetUseDwn then
  for i := 1 to MapAttachmentsInfo.GetMaxSubIndex do begin
    if MapAttachmentsInfo.GetEnabled(i) then
    if (not MapAttachmentsInfo.GetAttachmentStorage(i).AttachmentExists(AttachmentID)) then begin
      // download to storage
      VURL := MapAttachmentsInfo.MakeFullURL(i, AttachmentID);
      if (Downloader.DoHttpRequest(VURL, '', '', VResponseHeader, VResponseData)=200) then begin
        // downloaded
        MapAttachmentsInfo.GetAttachmentStorage(i).SaveAttachment(AttachmentID, VResponseData);
      end;
    end;
  end;
  
  // make VImgURL
  if MapAttachmentsInfo.GetAttachmentStorage(1).AttachmentExists(AttachmentID) then begin
    // allow from local
    VImgURL := MapAttachmentsInfo.GetAttachmentStorage(1).GetAttachmentFilename(AttachmentID);
    VImgURL := 'file:///' + RegExprReplaceMatchSubStr(VImgURL,'\\','\/');
  end else begin
    // use original URL
    VImgURL := MapAttachmentsInfo.MakeFullURL(1, AttachmentID);
  end;
  
  // make VImgBIG
  if MapAttachmentsInfo.GetAttachmentStorage(2).AttachmentExists(AttachmentID) then begin
    // allow from local
    VImgBIG := MapAttachmentsInfo.GetAttachmentStorage(2).GetAttachmentFilename(AttachmentID);
    VImgBIG := 'file:///' + RegExprReplaceMatchSubStr(VImgBIG,'\\','\/');
  end else begin
    // use original URL
    VImgBIG := MapAttachmentsInfo.MakeFullURL(2, AttachmentID);
  end;
  
  // obtain description with tags
  VCaption := GetBetween(SourceText,'<h1>','</h1>');
  
  // get user info
  VUserNumber := GetBetween(SourceText,'panoramio.com/user/','</a>');
  VUserDescr := GetAfter('>',VUserNumber);
  VUserNumber := GetNumberAfter('panoramio.com/user/',SourceText);
  
  // make result html text
  ResultText := '<a href="'+VImgBIG+'"><img src="'+VImgURL+'" alt="  "></a><br>'+
                '<h1>'+VCaption+'</h1>'+
                ' : <a href="http://www.panoramio.com/user/'+VUserNumber+'">'+VUserDescr+'</a><br>'+
                '<a href="http://www.panoramio.com/photo/'+AttachmentID+'">   Panoramio</a>';



end.