Skip to content
Snippets Groups Projects
Commit 8c08db0a authored by Andreas Gohr's avatar Andreas Gohr
Browse files

strip default parameters from media URLs

Default parameters like cacheche or empty width or heights are stripped
from media URLs now.

darcs-hash:20080817134207-7ad00-4b53c1f9b121fcbb3e0c5cc38e672f1b20157956.gz
parent f46c9e83
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment