2008-12-13
furun
makes internalmedia accessible with html_medialink,
like internallink with html_wikilink
add in
inc\html.php
/**
* Convenience function to quickly build a medialink
*
*/
function html_medialink($src, $title=NULL, $align=NULL, $width=NULL, $height=NULL, $cache=NULL, $linking=NULL) {
static $xhtml_renderer = NULL;
if(is_null($xhtml_renderer)){
require_once(DOKU_INC.'inc/parser/xhtml.php');
$xhtml_renderer = new Doku_Renderer_xhtml();
}
return $xhtml_renderer->internalmedia($src, $title, $align, $width, $height, $cache, $linking, true);
}
change in
inc\parser\xhtml.php
function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL, $height=NULL,
$cache=NULL, $linking=NULL, $returnonly=false) {
global $ID;
resolve_mediaid(getNS($ID),$src, $exists);
$noLink = false;
$render = ($linking == 'linkonly') ? false : true;
$link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render);
list($ext,$mime,$dl) = mimetype($src);
if(substr($mime,0,5) == 'image' && $render){
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),($linking=='direct'));
}elseif($mime == 'application/x-shockwave-flash' && $render){
// don't link flash movies
$noLink = true;
}else{
// add file icons
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
$link['class'] .= ' mediafile mf_'.$class;
$link['url'] = ml($src,array('id'=>$ID,'cache'=>$cache),true);
}
//markup non existing files
if (!$exists)
$link['class'] .= ' wikilink2';
//output formatted
if($returnonly){
if ($linking == 'nolink' || $noLink) return $link['name'];
else return $this->_formatLink($link);
}else{
if ($linking == 'nolink' || $noLink) $this->doc .= $link['name'];
else $this->doc .= $this->_formatLink($link);
}
}
2014-12-11
furun
yes, the reason for the feature request was plugins i made, in which i used html_externallink, html_internallink, html_externalmedia... to create dw conform links. (not syntax plugins)
a other situation i had to regexp-change the results of one of the functions before rendering. (i don't remember anymore way..)
i had to copy and recode some of the functions, to be able to use the functions freely. (never nice :-)
but i know how difficult it can be if redesigns of code curses a lot of trouble whit dependent code, even of 3. party plugins....!
(personal note: i use Github now a bit, before i had to be able to work offline, and patch/diff was there the best wen anyway sometimes painful compromise. i am only not sure if dw likes "improvements" and what is improving, beside of security patches.)