Browse Source

Enable thumbnailing

spaghetti 7 years ago
parent
commit
2329f52a6c

+ 3
- 3
classes/imagetools.class.php View File

@@ -11,12 +11,12 @@ class ImageTools {
11 11
    * @param string $Url image URL
12 12
    * @return image proxy URL
13 13
    */
14
-  public static function proxy_url($Url) {
14
+  public static function proxy_url($Url, $Thumb = false) {
15 15
     if (preg_match('/^https:\/\/('.SITE_DOMAIN.'|'.IMAGE_DOMAIN.')\//', $Url) || $Url[0]=='/') {
16 16
       if (strpos($Url, '?') === false) $Url .= '?';
17 17
       return $Url;
18 18
     } else {
19
-      return 'https://'.IMAGE_DOMAIN.'/?h='.rawurlencode(base64_encode(hash_hmac('sha256', $Url, IMAGE_PSK, true))).'&i='.urlencode($Url);
19
+      return 'https://'.IMAGE_DOMAIN.($Thumb?'/thumb/':'/').'?h='.rawurlencode(base64_encode(hash_hmac('sha256', $Url, IMAGE_PSK, true))).'&i='.urlencode($Url);
20 20
     }
21 21
   }
22 22
 
@@ -28,7 +28,7 @@ class ImageTools {
28 28
    */
29 29
   public static function process($Url = '', $Thumb = false) {
30 30
     // TODO: Thumbnailing
31
-    return $Url ? self::proxy_url($Url) : '';
31
+    return $Url ? self::proxy_url($Url, $Thumb) : '';
32 32
   }
33 33
 
34 34
   /**

+ 2
- 2
sections/torrents/browse.php View File

@@ -524,7 +524,7 @@ View::show_header('Browse Torrents', 'browse');
524 524
     $CoverArt = $GroupInfo['WikiImage'];
525 525
     $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
526 526
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
527
-      $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($CoverArt)."\" onmouseleave=\"ungetCover(event)\" ";
527
+      $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($CoverArt, true)."\" onmouseleave=\"ungetCover(event)\" ";
528 528
     }
529 529
     $DisplayName .= "dir=\"ltr\">$GroupName</a>";
530 530
     if ($GroupYear) {
@@ -642,7 +642,7 @@ $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGr
642 642
     $CoverArt = $GroupInfo['WikiImage'];
643 643
     $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
644 644
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
645
-      $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($CoverArt)."\" onmouseleave=\"ungetCover(event)\" ";
645
+      $DisplayName .= "onmouseover=\"getCover(event)\" data-cover=\"".ImageTools::process($CoverArt, true)."\" onmouseleave=\"ungetCover(event)\" ";
646 646
     }
647 647
     $DisplayName .= "dir=\"ltr\">$GroupName</a>";
648 648
     if (isset($GroupedCategories[$CategoryID - 1])) {

+ 6
- 5
sections/torrents/details.php View File

@@ -186,7 +186,7 @@ View::show_header($Title, 'browse,comments,torrent,bbcode,recommend,cover_art,su
186 186
 <div id="covers">
187 187
 <div id="cover_div_<?=$Index?>">
188 188
 <?  if ($WikiImage != '') { ?>
189
-      <div><img width="100%" class="lightbox-init" src="<?=ImageTools::process($WikiImage, true)?>" alt="<?=$AltName?>" /></div>
189
+      <div><img width="100%" class="lightbox-init" src="<?=ImageTools::process($WikiImage, true)?>" lightbox-img="<?=ImageTools::process($WikiImage)?>" alt="<?=$AltName?>" /></div>
190 190
 <?  } else { ?>
191 191
       <div><img width="100%" src="<?=STATIC_SERVER?>common/noartwork/nocover.png" alt="<?=$Categories[$GroupCategoryID - 1]?>" class="brackets tooltip" title="<?=$Categories[$GroupCategoryID - 1]?>" /></div>
192 192
 <?
@@ -201,9 +201,9 @@ $Index++;
201 201
         <div>
202 202
 <?
203 203
           if (empty($LoggedUser['ShowExtraCovers'])) {
204
-            $Src = 'src="" data-gazelle-temp-src="' . ImageTools::process($Image, true) . '"';
204
+            $Src = 'src="" data-gazelle-temp-src="' . ImageTools::process($Image, true) . '" lightbox-img="'.ImageTools::process($Image).'"';
205 205
           } else {
206
-            $Src = 'src="' . ImageTools::process($Image, true) . '"';
206
+            $Src = 'src="' . ImageTools::process($Image, true) . '" lightbox-img="'.ImageTools::process($Image).'"';
207 207
           }
208 208
 ?>
209 209
           <img id="cover_<?=$Index?>" class="lightbox-init" width="100%" <?=$Src?> alt="<?=$Summary?>" />
@@ -778,10 +778,11 @@ if (count($PersonalCollages) > 0) {
778 778
 <?
779 779
     foreach($Screenshots as $Screenshot) {
780 780
       $SSURL = ImageTools::process($Screenshot['Image']);
781
+      $ThumbURL = ImageTools::process($Screenshot['Image'], true);
781 782
       if (check_perms('users_mod')) {
782
-        ?><img class='tooltip lightbox-init' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' data-src="<?=$SSURL?>" /><?
783
+        ?><img class='tooltip lightbox-init' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' lightbox-img="<?=$SSURL?>" src="<?=$ThumbURL?>" /><?
783 784
       } else {
784
-        ?><img class='tooltip lightbox-init' title='Added <?=time_diff($Screenshot['Time'])?>' data-src="<?=$SSURL?>" /><?
785
+        ?><img class='tooltip lightbox-init' title='Added <?=time_diff($Screenshot['Time'])?>' lightbox-img="<?=$SSURL?>" src="<?=$ThumbURL?>" /><?
785 786
       }
786 787
     }
787 788
 ?>

+ 0
- 7
static/functions/browse.js View File

@@ -280,11 +280,4 @@ $(function() {
280 280
     var els = $('#torrent_table.grouping .colhead td:first-child(), #torrent_table.grouping .colhead_dark td:first-child(), #torrent_table.grouping .torrent td:first-child()')
281 281
     for (var i = 0; i < els.length; i++) { els[i].style.display = 'none' }
282 282
   }
283
-/*
284
-  //Preload first result's cover
285
-  if ($('#torrent_table').length > 0) {
286
-    var a = $('a[data-cover]')[0]
287
-    if (a) preload(a.attributes['data-cover'].value)
288
-  }
289
- */
290 283
 })

+ 2
- 10
static/functions/global.js View File

@@ -260,7 +260,7 @@ window.onkeydown = function(e) {
260 260
   e = e || window.event
261 261
   if (e.keyCode == 37 || e.keyCode == 39) {
262 262
     if ($('#lightbox').raw() && !$('#lightbox').raw().classList.contains('hidden')) {
263
-      ($('[id!="lightbox"] > [src="'+$('#lightbox > img').raw().src+'"]').raw()[((e.keyCode==39)?'next':'previous')+'Sibling'].click()||function(){})()
263
+      ($('[id!="lightbox"] > [lightbox-img="'+$('#lightbox > img').raw().src+'"]').raw()[((e.keyCode==39)?'next':'previous')+'Sibling'].click()||function(){})()
264 264
     }
265 265
   }
266 266
 }
@@ -311,7 +311,6 @@ function getCover(event) {
311 311
   $('#coverCont img')[0].src = image?image:'/static/common/noartwork/nocover.png'
312 312
   coverCont.className = (event.clientX > (window.innerWidth/2)) ? 'left' : 'right'
313 313
   coverCont.style.display = 'block'
314
-/*
315 314
   //Preload next image
316 315
   if ($('.torrent_table, .request_table').length > 0) {
317 316
     var as = $('[data-cover]')
@@ -319,7 +318,6 @@ function getCover(event) {
319 318
     preload((as[as.toArray().indexOf(a)+1]||as[0]).attributes['data-cover'].value)
320 319
     preload((as[as.toArray().indexOf(a)-1]||as[0]).attributes['data-cover'].value)
321 320
   }
322
-*/
323 321
 }
324 322
 function ungetCover(event) {
325 323
   $('#coverCont img').remove()
@@ -333,12 +331,6 @@ if (typeof NodeList.prototype.forEach !== 'function') {
333 331
 }
334 332
 
335 333
 $(function() {
336
-/*
337
-  if ($('.request_table').length > 0) {
338
-    var a = $('[data-cover]')[0]
339
-    if (a) preload(a.attributes['data-cover'].value)
340
-  }
341
-*/
342 334
   document.querySelectorAll('[data-toggle-target]').forEach(function(el) {
343 335
     el.addEventListener('click', function(event) {
344 336
       $(el.attributes['data-toggle-target'].value).gtoggle()
@@ -349,6 +341,6 @@ $(function() {
349 341
   })
350 342
 
351 343
   $(document).on('click', '.lightbox-init', function(e) {
352
-    lightbox.init(e.target.attributes['lightbox-img']||e.target.src, e.target.attributes['lightbox-size']||e.target.width)
344
+    lightbox.init((e.target.attributes['lightbox-img']||[]).value||e.target.src, (e.target.attributes['lightbox-size']||[]).value||e.target.width)
353 345
   })
354 346
 })

+ 0
- 8
static/functions/torrent.js View File

@@ -188,11 +188,3 @@ function Vote(amount, requestid) {
188 188
     }
189 189
   );
190 190
 }
191
-
192
-$(() => {
193
-  $('.torrent_screenshots_box > .head > a[data-toggle-replace]').on('click', event => {
194
-    $('.torrent_screenshots > img').each((i, el) => {
195
-      el.src = $(el).data('src')
196
-    })
197
-  })
198
-})

Loading…
Cancel
Save