From 8c08db0a936bb99814fc12a60e2717882b6f9ee4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 17 Aug 2008 15:42:07 +0200 Subject: strip default parameters from media URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default parameters like cacheÊche or empty width or heights are stripped from media URLs now. darcs-hash:20080817134207-7ad00-4b53c1f9b121fcbb3e0c5cc38e672f1b20157956.gz --- inc/common.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'inc/common.php') 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); } -- cgit v1.2.3