Empty commit

This commit is contained in:
Git 2012-06-22 08:00:10 +00:00
parent 78837ab056
commit c4345798c8
7 changed files with 57 additions and 42 deletions

View File

@ -4,12 +4,15 @@
* *
**/ **/
function to_thumbnail($url) { function to_thumbnail($url) {
$thumb = $url; $thumb = $url;
$extension = pathinfo($url, PATHINFO_EXTENSION); $extension = pathinfo($url, PATHINFO_EXTENSION);
if(contains('whatimg', $url)) { if(contains('whatimg', $url)) {
if($extension == 'jpeg' || $extension == 'jpg') { if(hasWhatImgThumb($url)) {
if($extension == 'jpeg') {
$thumb = replace_extension($url, '_thumb.jpeg');
}
if($extension == 'jpg') {
$thumb = replace_extension($url, '_thumb.jpg'); $thumb = replace_extension($url, '_thumb.jpg');
} }
if($extension == 'png') { if($extension == 'png') {
@ -19,7 +22,9 @@ function to_thumbnail($url) {
$thumb = replace_extension($url, '_thumb.gif'); $thumb = replace_extension($url, '_thumb.gif');
} }
} }
}
elseif(contains('imgur', $url)) { elseif(contains('imgur', $url)) {
$url = cleanImgurUrl($url);
if($extension == 'jpeg') { if($extension == 'jpeg') {
$thumb = replace_extension($url, 'm.jpeg'); $thumb = replace_extension($url, 'm.jpeg');
} }
@ -44,13 +49,21 @@ function replace_extension($string, $extension) {
} }
function contains($substring, $string) { function contains($substring, $string) {
$pos = strpos($string, $substring); return $pos = strpos($string, $substring);
if($pos === false) {
return false;
}
else {
return true;
} }
function hasWhatImgThumb($url) {
return !contains("_thumb", $url);
}
function cleanImgurUrl($url) {
$extension = pathinfo($url, PATHINFO_EXTENSION);
$path = preg_replace('/\.[^.]*$/', '', $url);
$last = $path[strlen($path)-1];
if($last == 'm' || $last == 'l' || $last == 's' || $last == 'h' || $last == 'b') {
$path = substr($path, 0, -1);
}
return $path . "." . $extension;
} }
?> ?>

View File

@ -520,7 +520,7 @@ function compare($X, $Y){
<div class="box"> <div class="box">
<div class="head"><strong><?=$Name?></strong></div> <div class="head"><strong><?=$Name?></strong></div>
<div style="text-align:center;padding:10px 0px;"> <div style="text-align:center;padding:10px 0px;">
<img style="max-width: 220px;" src="<?=$Image?>" alt="<?=$Name?>" onclick="lightbox.init(this,220);" /> <img style="max-width: 220px;" src="<?=to_thumbnail($Image)?>" alt="<?=$Name?>" onclick="lightbox.init('<?=$Image?>',220);" />
</div> </div>
</div> </div>
<? } ?> <? } ?>

View File

@ -285,7 +285,7 @@ function compare($X, $Y){
$Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image); $Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image);
} }
?> ?>
<img src="<?=$Image?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?>" width="117" /> <img src="<?=to_thumbnail($Image)?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?>" width="117" />
<? } else { ?> <? } else { ?>
<div style="width:107px;padding:5px"><?=$DisplayName?></div> <div style="width:107px;padding:5px"><?=$DisplayName?></div>
<? } ?> <? } ?>

View File

@ -324,7 +324,7 @@ function compare($X, $Y){
$Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image); $Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image);
} }
?> ?>
<img src="<?=$Image?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?>" width="118" /> <img src="<?=to_thumbnail($Image)?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?>" width="118" />
<? } else { ?> <? } else { ?>
<div style="width:107px;padding:5px"><?=$DisplayName?></div> <div style="width:107px;padding:5px"><?=$DisplayName?></div>
<? } ?> <? } ?>

View File

@ -6,6 +6,8 @@
include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked() include(SERVER_ROOT.'/sections/bookmarks/functions.php'); // has_bookmarked()
include(SERVER_ROOT.'/classes/class_text.php'); include(SERVER_ROOT.'/classes/class_text.php');
include(SERVER_ROOT.'/classes/class_image_tools.php');
$Text = new TEXT; $Text = new TEXT;
if(empty($_GET['id']) || !is_number($_GET['id'])) { if(empty($_GET['id']) || !is_number($_GET['id'])) {
@ -115,7 +117,7 @@
$Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image); $Image = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($Image);
} }
?> ?>
<p align="center"><img style="max-width: 220px;" src="<?=$Image?>" alt="<?=$FullName?>" onclick="lightbox.init(this,220);" /></p> <p align="center"><img style="max-width: 220px;" src="<?=to_thumbnail($Image)?>" alt="<?=$FullName?>" onclick="lightbox.init('<?=$Image?>',220);" /></p>
<? } else { ?> <? } else { ?>
<p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$CategoryID-1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p> <p align="center"><img src="<?=STATIC_SERVER?>common/noartwork/<?=$CategoryIcons[$CategoryID-1]?>" alt="<?=$CategoryName?>" title="<?=$CategoryName?>" width="220" height="220" border="0" /></p>
<? } ?> <? } ?>

View File

@ -121,7 +121,7 @@ function compare($X, $Y){
$WikiImage = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($WikiImage); $WikiImage = 'http'.($SSL?'s':'').'://'.SITE_URL.'/image.php?i='.urlencode($WikiImage);
} }
?> ?>
<p align="center"><img style="max-width: 220px;" src="<?=$WikiImage?>" alt="<?=$AltName?>" onclick="lightbox.init(this,220);" /></p> <p align="center"><img style="max-width: 220px;" src="<?=to_thumbnail($WikiImage)?>" alt="<?=$AltName?>" onclick="lightbox.init('<?=$WikiImage?>',220);" /></p>
<? <?
} else { } else {
?> ?>

View File

@ -412,7 +412,7 @@ function check_paranoia_here($Setting) {
if (check_perms('users_view_keys',$Class) || $OwnProfile) { if (check_perms('users_view_keys',$Class) || $OwnProfile) {
?> ?>
<li>Passkey: <a href="#" onclick="this.innerHTML='<?=display_str($torrent_pass)?>'; return false;">[view]</a></li> <li>Passkey: <a href="#" onclick="this.innerHTML='<?=display_str($torrent_pass)?>'; return false;">[View]</a></li>
<? } <? }
if (check_perms('users_view_invites')) { if (check_perms('users_view_invites')) {
if (!$InviterID) { if (!$InviterID) {
@ -643,7 +643,7 @@ function check_paranoia_here($Setting) {
<? <?
foreach($RecentSnatches as $RS) { ?> foreach($RecentSnatches as $RS) { ?>
<td> <td>
<a href="torrents.php?id=<?=$RS['ID']?>" title="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>"><img src="<?=$RS['WikiImage']?>" alt="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>" width="107" /></a> <a href="torrents.php?id=<?=$RS['ID']?>" title="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>"><img src="<?=to_thumbnail($RS['WikiImage'])?>" alt="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>" width="107" /></a>
</td> </td>
<? } ?> <? } ?>
</tr> </tr>
@ -682,7 +682,7 @@ function check_paranoia_here($Setting) {
<tr> <tr>
<? foreach($RecentUploads as $RU) { ?> <? foreach($RecentUploads as $RU) { ?>
<td> <td>
<a href="torrents.php?id=<?=$RU['ID']?>" title="<?=$RU['Artist']?><?=$RU['Name']?>"><img src="<?=$RU['WikiImage']?>" alt="<?=$RU['Artist']?><?=$RU['Name']?>" width="107" /></a> <a href="torrents.php?id=<?=$RU['ID']?>" title="<?=$RU['Artist']?><?=$RU['Name']?>"><img src="<?=to_thumbnail($RU['WikiImage'])?>" alt="<?=$RU['Artist']?><?=$RU['Name']?>" width="107" /></a>
</td> </td>
<? } ?> <? } ?>
</tr> </tr>
@ -726,7 +726,7 @@ function check_paranoia_here($Setting) {
$Name .= $GroupName; $Name .= $GroupName;
?> ?>
<td> <td>
<a href="torrents.php?id=<?=$GroupID?>" title="<?=$Name?>"><img src="<?=$C['WikiImage']?>" alt="<?=$Name?>" width="107" /></a> <a href="torrents.php?id=<?=$GroupID?>" title="<?=$Name?>"><img src="<?=to_thumbnail($C['WikiImage'])?>" alt="<?=$Name?>" width="107" /></a>
</td> </td>
<? } ?> <? } ?>
</tr> </tr>