Browse Source

Enable thumbnailing

spaghetti 7 years ago
parent
commit
2329f52a6c

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

11
    * @param string $Url image URL
11
    * @param string $Url image URL
12
    * @return image proxy URL
12
    * @return image proxy URL
13
    */
13
    */
14
-  public static function proxy_url($Url) {
14
+  public static function proxy_url($Url, $Thumb = false) {
15
     if (preg_match('/^https:\/\/('.SITE_DOMAIN.'|'.IMAGE_DOMAIN.')\//', $Url) || $Url[0]=='/') {
15
     if (preg_match('/^https:\/\/('.SITE_DOMAIN.'|'.IMAGE_DOMAIN.')\//', $Url) || $Url[0]=='/') {
16
       if (strpos($Url, '?') === false) $Url .= '?';
16
       if (strpos($Url, '?') === false) $Url .= '?';
17
       return $Url;
17
       return $Url;
18
     } else {
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
    */
28
    */
29
   public static function process($Url = '', $Thumb = false) {
29
   public static function process($Url = '', $Thumb = false) {
30
     // TODO: Thumbnailing
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
     $CoverArt = $GroupInfo['WikiImage'];
524
     $CoverArt = $GroupInfo['WikiImage'];
525
     $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
525
     $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
526
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
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
     $DisplayName .= "dir=\"ltr\">$GroupName</a>";
529
     $DisplayName .= "dir=\"ltr\">$GroupName</a>";
530
     if ($GroupYear) {
530
     if ($GroupYear) {
642
     $CoverArt = $GroupInfo['WikiImage'];
642
     $CoverArt = $GroupInfo['WikiImage'];
643
     $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
643
     $DisplayName .= "<a class=\"torrent_name\" href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID#torrent$TorrentID\" ";
644
     if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
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
     $DisplayName .= "dir=\"ltr\">$GroupName</a>";
647
     $DisplayName .= "dir=\"ltr\">$GroupName</a>";
648
     if (isset($GroupedCategories[$CategoryID - 1])) {
648
     if (isset($GroupedCategories[$CategoryID - 1])) {

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

186
 <div id="covers">
186
 <div id="covers">
187
 <div id="cover_div_<?=$Index?>">
187
 <div id="cover_div_<?=$Index?>">
188
 <?  if ($WikiImage != '') { ?>
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
 <?  } else { ?>
190
 <?  } else { ?>
191
       <div><img width="100%" src="<?=STATIC_SERVER?>common/noartwork/nocover.png" alt="<?=$Categories[$GroupCategoryID - 1]?>" class="brackets tooltip" title="<?=$Categories[$GroupCategoryID - 1]?>" /></div>
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
         <div>
201
         <div>
202
 <?
202
 <?
203
           if (empty($LoggedUser['ShowExtraCovers'])) {
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
           } else {
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
           <img id="cover_<?=$Index?>" class="lightbox-init" width="100%" <?=$Src?> alt="<?=$Summary?>" />
209
           <img id="cover_<?=$Index?>" class="lightbox-init" width="100%" <?=$Src?> alt="<?=$Summary?>" />
778
 <?
778
 <?
779
     foreach($Screenshots as $Screenshot) {
779
     foreach($Screenshots as $Screenshot) {
780
       $SSURL = ImageTools::process($Screenshot['Image']);
780
       $SSURL = ImageTools::process($Screenshot['Image']);
781
+      $ThumbURL = ImageTools::process($Screenshot['Image'], true);
781
       if (check_perms('users_mod')) {
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
       } else {
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
     var els = $('#torrent_table.grouping .colhead td:first-child(), #torrent_table.grouping .colhead_dark td:first-child(), #torrent_table.grouping .torrent td:first-child()')
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
     for (var i = 0; i < els.length; i++) { els[i].style.display = 'none' }
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
   e = e || window.event
260
   e = e || window.event
261
   if (e.keyCode == 37 || e.keyCode == 39) {
261
   if (e.keyCode == 37 || e.keyCode == 39) {
262
     if ($('#lightbox').raw() && !$('#lightbox').raw().classList.contains('hidden')) {
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
   $('#coverCont img')[0].src = image?image:'/static/common/noartwork/nocover.png'
311
   $('#coverCont img')[0].src = image?image:'/static/common/noartwork/nocover.png'
312
   coverCont.className = (event.clientX > (window.innerWidth/2)) ? 'left' : 'right'
312
   coverCont.className = (event.clientX > (window.innerWidth/2)) ? 'left' : 'right'
313
   coverCont.style.display = 'block'
313
   coverCont.style.display = 'block'
314
-/*
315
   //Preload next image
314
   //Preload next image
316
   if ($('.torrent_table, .request_table').length > 0) {
315
   if ($('.torrent_table, .request_table').length > 0) {
317
     var as = $('[data-cover]')
316
     var as = $('[data-cover]')
319
     preload((as[as.toArray().indexOf(a)+1]||as[0]).attributes['data-cover'].value)
318
     preload((as[as.toArray().indexOf(a)+1]||as[0]).attributes['data-cover'].value)
320
     preload((as[as.toArray().indexOf(a)-1]||as[0]).attributes['data-cover'].value)
319
     preload((as[as.toArray().indexOf(a)-1]||as[0]).attributes['data-cover'].value)
321
   }
320
   }
322
-*/
323
 }
321
 }
324
 function ungetCover(event) {
322
 function ungetCover(event) {
325
   $('#coverCont img').remove()
323
   $('#coverCont img').remove()
333
 }
331
 }
334
 
332
 
335
 $(function() {
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
   document.querySelectorAll('[data-toggle-target]').forEach(function(el) {
334
   document.querySelectorAll('[data-toggle-target]').forEach(function(el) {
343
     el.addEventListener('click', function(event) {
335
     el.addEventListener('click', function(event) {
344
       $(el.attributes['data-toggle-target'].value).gtoggle()
336
       $(el.attributes['data-toggle-target'].value).gtoggle()
349
   })
341
   })
350
 
342
 
351
   $(document).on('click', '.lightbox-init', function(e) {
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
     }
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