image refresher

This commit is contained in:
2016-04-17 01:38:55 +02:00
parent 9d7e64ce22
commit 4a6a372fab
6 changed files with 20 additions and 8 deletions

View File

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@@ -2,6 +2,8 @@
require_once 'settings.php';
define(TMP_FOLDER, 'tmp/');
function getPage($sPath, $asVars, $sType)
{
$bSavePage = Settings::DEBUG;
@@ -9,7 +11,7 @@ function getPage($sPath, $asVars, $sType)
{
$asFileIds = array_filter($asVars);
unset($asFileIds['_']);
$sFileName = $sPath.'.'.implode('.', $asFileIds).'.log';
$sFileName = TMP_FOLDER.$sPath.'.'.implode('.', $asFileIds).'.log';
}
if(!$bSavePage || !file_exists($sFileName) || date('dmY', filemtime($sFileName))!=date('dmY'))
{
@@ -45,10 +47,11 @@ function setPageMime($sType='html')
if($sType!='html' && array_key_exists($sType, $asMainTypes)) header('Content-type: '.$asMainTypes[$sType].'/'.$sType);
}
function getTrimImage($iFilmId, $sSize, $sinPath, $sImageExt)
function getTrimImage($iFilmId, $sSize, $sinPath, $sImageExt, $bForce=false)
{
$sOutPath = 'images/'.$iFilmId.'_'.$sSize.'.'.$sImageExt;
if(!file_exists($sOutPath))
$sOutPath = TMP_FOLDER.$iFilmId.'_'.$sSize.'.'.$sImageExt;
$bFileExist = file_exists($sOutPath);
if(!$bFileExist || $bForce)
{
$oImage = call_user_func('imagecreatefrom'.$sImageExt, $sinPath);
$iImageX = imagesx($oImage);
@@ -117,6 +120,10 @@ function getTrimImage($iFilmId, $sSize, $sinPath, $sImageExt)
//Copy the content, excluding the border
imagecopy($oCropImage, $oImage, 0, 0, $iLeft, $iTop, imagesx($oCropImage), imagesy($oCropImage));
//Remove existing image
if($bFileExist) unlink($sOutPath);
//Store image
call_user_func_array('image'.$sImageExt, array($oCropImage, $sOutPath));
}

View File

@@ -12,7 +12,7 @@ switch($sAction)
$sResult = getPage($asData['path'], $asData['vars'], $sType);
break;
case 'get_poster':
$sResult = getTrimImage($asData['id'], $asData['size'], $asData['url'], $sType);
$sResult = getTrimImage($asData['id'], $asData['size'], $asData['url'], $sType, $asData['force']);
break;
default:
$sResult = file_get_contents('masks/index.html');

View File

@@ -4,8 +4,8 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="author" content="Franzz" />
<meta name="viewport" content="width=device-width, initial-scale=0.5">
<link rel='shortcut icon' href='favicon.ico' type='image/x-icon' />
<link rel='stylesheet' href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' type='text/css'>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic" type="text/css" />
<link rel="stylesheet" href="style/ugc.css" type="text/css" />
<script type="text/javascript" src="script/jquery.js"></script>
<script type="text/javascript" src="script/ugc.js"></script>

View File

@@ -103,7 +103,12 @@ function Film(oSettings)
this._anchor = $('<div>', {'class':'film', 'id':'film_'+this.id()})
.data('id', this.id())
.append($('<img>', {'class':'bg', 'src':this.backgroundPoster()}))
.append($('<div>', {'class':'poster-container'}).append($('<img>', {'class':'poster', 'src':this.backgroundPoster()})))
.append($('<div>', {'class':'poster-container'})
.append($('<img>', {'class':'poster', 'src':this.backgroundPoster()})
.click(function(){
$This = $(this);
$This.attr('src', $This.attr('src')+'&data[force]=1');
})))
.append($('<div>', {'class':'info'})
.append($('<p>', {'class':'title'})
.append($('<a>', {'class':'name', 'target':'_blank', 'href':this.consts.ugc_url+'film.html?id='+this.id()})

BIN
tmp/11000_medium.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB