mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 01:03:31 +02:00
feature 2548 multisize - improved picture.php display (original...) + code cleanup
git-svn-id: http://piwigo.org/svn/trunk@12855 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -138,9 +138,8 @@ final class DerivativeImage
|
||||
return get_root_url().$rel_url;
|
||||
}
|
||||
|
||||
static function get_all($infos)
|
||||
static function get_all($src_image)
|
||||
{
|
||||
$src_image = new SrcImage($infos);
|
||||
$ret = array();
|
||||
foreach (ImageStdParams::get_defined_type_map() as $type => $params)
|
||||
{
|
||||
|
||||
@@ -740,6 +740,20 @@ function original_to_representative($path, $representative_ext)
|
||||
return substr_replace($path, $representative_ext, $pos+1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_path($element_info)
|
||||
{
|
||||
$path = $element_info['path'];
|
||||
if ( !url_is_remote($path) )
|
||||
{
|
||||
$path = PHPWG_ROOT_PATH.$path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
/* Returns the PATH to the thumbnail to be displayed. If the element does not
|
||||
* have a thumbnail, the default mime image path is returned. The PATH can be
|
||||
|
||||
@@ -21,48 +21,6 @@
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_path($element_info)
|
||||
{
|
||||
$path = get_element_location($element_info);
|
||||
if ( !url_is_remote($path) )
|
||||
{
|
||||
$path = PHPWG_ROOT_PATH.$path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_url($element_info)
|
||||
{
|
||||
$url = get_element_location($element_info);
|
||||
if ( !url_is_remote($url) )
|
||||
{
|
||||
$url = embellish_url(get_root_url().$url);
|
||||
}
|
||||
// plugins want another url ?
|
||||
return trigger_event('get_element_url', $url, $element_info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative path of the element with regards to to the root
|
||||
* of PWG (not the current page). This function is not intended to be
|
||||
* called directly from code.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_location($element_info)
|
||||
{
|
||||
// maybe a cached watermark ?
|
||||
return trigger_event('get_element_location',
|
||||
$element_info['path'], $element_info);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -83,100 +41,6 @@ function get_image_name($name, $filename)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the PATH to the image to be displayed in the picture page. If the
|
||||
* element is not a picture, then the representative image or the default
|
||||
* mime image. The path can be used in the php script, but not sent to the
|
||||
* browser.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'representative_ext' should be present
|
||||
*/
|
||||
function get_image_path($element_info)
|
||||
{
|
||||
global $conf;
|
||||
$ext = get_extension($element_info['path']);
|
||||
if (in_array($ext, $conf['picture_ext']))
|
||||
{
|
||||
if (isset($element_info['element_path']) )
|
||||
{
|
||||
return $element_info['element_path'];
|
||||
}
|
||||
return get_element_path($element_info);
|
||||
}
|
||||
|
||||
$path = get_image_location($element_info);
|
||||
if ( !url_is_remote($path) )
|
||||
{
|
||||
$path = PHPWG_ROOT_PATH.$path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the image to be displayed in the picture page. If the
|
||||
* element is not a picture, then the representative image or the default
|
||||
* mime image. The URL can't be used in the php script, but can be sent to the
|
||||
* browser.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'representative_ext' should be present
|
||||
*/
|
||||
function get_image_url($element_info)
|
||||
{
|
||||
global $conf;
|
||||
$ext = get_extension($element_info['path']);
|
||||
if (in_array($ext, $conf['picture_ext']))
|
||||
{
|
||||
if (isset($element_info['element_url']) )
|
||||
{
|
||||
return $element_info['element_url'];
|
||||
}
|
||||
return get_element_url($element_info);
|
||||
}
|
||||
|
||||
$url = get_image_location($element_info);
|
||||
if ( !url_is_remote($url) )
|
||||
{
|
||||
$url = embellish_url(get_root_url().$url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the relative path of the image (element/representative/mimetype)
|
||||
* with regards to the root of PWG (not the current page). This function
|
||||
* is not intended to be called directly from code.
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'representative_ext' should be present
|
||||
*/
|
||||
function get_image_location($element_info)
|
||||
{
|
||||
if (isset($element_info['representative_ext'])
|
||||
and $element_info['representative_ext'] != '')
|
||||
{
|
||||
$pi = pathinfo($element_info['path']);
|
||||
$file_wo_ext = get_filename_wo_extension($pi['basename']);
|
||||
$path =
|
||||
$pi['dirname'].'/pwg_representative/'
|
||||
.$file_wo_ext.'.'.$element_info['representative_ext'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ext = get_extension($element_info['path']);
|
||||
$path = get_themeconf('mime_icon_dir');
|
||||
$path.= strtolower($ext).'.png';
|
||||
if ( !file_exists(PHPWG_ROOT_PATH.$path)
|
||||
and !empty($element_info['tn_ext']) )
|
||||
{
|
||||
$path = get_thumbnail_location($element_info);
|
||||
}
|
||||
}
|
||||
|
||||
// plugins want another location ?
|
||||
return trigger_event( 'get_image_location', $path, $element_info);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path', 'has_high' should be present
|
||||
@@ -222,23 +86,6 @@ function get_high_location($element_info)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param what_part string one of 't' (thumbnail), 'e' (element), 'i' (image),
|
||||
* 'h' (high resolution image)
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_download_url($what_part, $element_info)
|
||||
{
|
||||
$url = get_root_url().'action.php';
|
||||
$url = add_url_params($url,
|
||||
array(
|
||||
'id' => $element_info['id'],
|
||||
'part' => $what_part,
|
||||
)
|
||||
);
|
||||
return trigger_event( 'get_download_url', $url, $element_info);
|
||||
}
|
||||
|
||||
/*
|
||||
* get slideshow default params into array
|
||||
|
||||
@@ -660,6 +660,40 @@ function parse_well_known_params_url($tokens, &$i)
|
||||
return $page;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param id image id
|
||||
* @param what_part string one of 'e' (element), 'r' (representative)
|
||||
*/
|
||||
function get_action_url($id, $what_part, $download)
|
||||
{
|
||||
$params = array(
|
||||
'id' => $id,
|
||||
'part' => $what_part,
|
||||
);
|
||||
if ($download)
|
||||
{
|
||||
$params['download'] = null;
|
||||
}
|
||||
|
||||
return add_url_params(get_root_url().'action.php', $params);
|
||||
}
|
||||
|
||||
/*
|
||||
* @param element_info array containing element information from db;
|
||||
* at least 'id', 'path' should be present
|
||||
*/
|
||||
function get_element_url($element_info)
|
||||
{
|
||||
$url = $element_info['path'];
|
||||
if ( !url_is_remote($url) )
|
||||
{
|
||||
$url = embellish_url(get_root_url().$url);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicate to build url with full path
|
||||
*
|
||||
|
||||
@@ -147,13 +147,16 @@ function ws_std_image_sql_order( $params, $tbl_name='' )
|
||||
function ws_std_get_urls($image_row)
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
$src_image = new SrcImage($image_row);
|
||||
|
||||
global $user;
|
||||
if ($user['enabled_high'])
|
||||
{
|
||||
$ret['element_url'] = get_element_url($image_row);
|
||||
}
|
||||
|
||||
$derivatives = DerivativeImage::get_all($image_row);
|
||||
$derivatives = DerivativeImage::get_all($src_image);
|
||||
$derivatives_arr = array();
|
||||
foreach($derivatives as $type=>$derivative)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user