Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
test
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2022-11-25 21:27:34
This will automatically render any image urls in the torrent description as a HTML image tag. Images will show right away. Also, domain is listed under each image.

HTML can be replaced with BBCode (edit the markup).

Add to backend/functions.php:


function format_media(string $body): string
{
   $i = 0;
   return preg_replace_callback('~(http.*\.)(jpe?g|png|[tg]iff?|svg)~i', function($matches) use (&$i)
   {
       $i++;
       if (isset($matches[3])) {
           return "<a href='{$matches[2]}{$matches[3]}' target='_blank'><img src='{$matches[2]}{$matches[3]}' style='width:90px;height:90px;border-radius:4px'></a>";
       } else {
           $domain = parse_url($matches[1], PHP_URL_HOST);
           return "<div style='padding:5px;background:#d2d2d2;border-radius:4px;width:150px'><a href='{$matches[1]}{$matches[2]}' target='_blank'><img src='{$matches[1]}{$matches[2]}' style='width:100%;height:90px;border-radius:4px'></a><div style='text-align:center;margin-top:-3px'>$i - $domain</div></div>";
       }
   }, format_comment($body));
}


Open torrents-details.php and find:


print("<tr><td align='left' colspan='2'><b>" .T_("DESCRIPTION"). ":</b><br />" .  format_comment($row['descr']) . "</td></tr>\n");


Replace with:


print("<tr><td align='left' colspan='2'><b>" .T_("DESCRIPTION"). ":</b><br />" .  format_media($row['descr']) . "</td></tr>\n");


Example:

Last edited by STorrents2020 on 2022-11-25 21:38:53
2022-11-26 14:10:10
hello friend STorrents2020

Well dressed but it brings breaks in the theme, on my side I pre defined my images by the css and creation of tag like [img1] class= .cover_img and I added to my tag size cover, DVD, CDs etc.

 it allows me not to have to correct the sizes of the images of their URLs

My your code can be used on a page for another need and that is well dressed!

It works well, thanks. 👍
Last edited by spiritblue on 2022-11-26 14:10:54
2022-11-26 17:51:50
Your welcome 😉
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 2
  • Members: 0
  • Guests online: 2
  • Comments: 3
  • Messages: 1,728