diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-08-17 15:42:07 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-08-17 15:42:07 +0200 |
commit | 8c08db0a936bb99814fc12a60e2717882b6f9ee4 (patch) | |
tree | cac50dfae227bac20601c91bf6cdf278ef3c30f9 | |
parent | f46c9e83ac3d4e9350bdc37645a5e337c24b1cac (diff) | |
download | rpg-8c08db0a936bb99814fc12a60e2717882b6f9ee4.tar.gz rpg-8c08db0a936bb99814fc12a60e2717882b6f9ee4.tar.bz2 |
strip default parameters from media URLs
Default parameters like cacheÊche or empty width or heights are stripped
from media URLs now.
darcs-hash:20080817134207-7ad00-4b53c1f9b121fcbb3e0c5cc38e672f1b20157956.gz
-rw-r--r-- | inc/common.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/inc/common.php b/inc/common.php index 1f7e3f910..9f52fea1b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -410,12 +410,28 @@ function exportlink($id='',$format='raw',$more='',$abs=false,$sep='&'){ * Build a link to a media file * * Will return a link to the detail page if $direct is false + * + * The $more parameter should always be given as array, the function then + * will strip default parameters to produce even cleaner URLs + * + * @param string $id - the media file id or URL + * @param mixed $more - string or array with additional parameters + * @param boolean $direct - link to detail page if false + * @param string $sep - URL parameter separator + * @param boolean $abs - Create an absolute URL */ function ml($id='',$more='',$direct=true,$sep='&',$abs=false){ global $conf; if(is_array($more)){ + // strip defaults for shorter URLs + if(isset($more['cache']) && $more['cache'] == 'cache') unset($more['cache']); + if(!$more['w']) unset($more['w']); + if(!$more['h']) unset($more['h']); + if(isset($more['id']) && $direct) unset($more['id']); $more = buildURLparams($more,$sep); }else{ + $more = str_replace('cache=cache','',$more); //skip default + $more = str_replace(',,',',',$more); $more = str_replace(',',$sep,$more); } |