-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
2.5.6, 2.7.2
-
None
-
MOODLE_25_STABLE, MOODLE_27_STABLE
Hi, guys!
Just resolved a bug in moodle that makes me angry. So i did auth module and wanted to make css with background and write like this: background-image: url('[[pix:auth_myplugin|myicon]]'); so it located at /auth/myplugin/pix/myicon.png BUT IT NOT WORKS, because Moodle makes path like this /theme/image.php/standard/core/1411564078/auth_myplugin/myicon
But it wrong, its not a core, its auth_myplugin. So i started to look for a bug, so file lib/outputlib.php in function resolve_image_location checks for $component at this place:
if (strpos($component, '_') === false)
its OK, but if it not mod_XXX = bug
so i resolved it:
file lib/outputlib.php -> function post_process(): 1298
look at 1307 and 1308:
$imagename = $match[2];
$component = rtrim($match[1], '|');
here is bug, because $match[1] is empty in our case!
FIX:
if ( !empty( $match[1] ) )
if ( !empty( $match[2] ) ) { $tmp_array = explode( '|' , $match[2]); $component = $tmp_array[0]; $imagename = $tmp_array[1]; }
}
so function post_process must be like this:
public function post_process($css) {
// now resolve all image locations
if (preg_match_all('/[[pix

$replaced = array();
foreach ($matches as $match) {//print_r($match);die;
if (isset($replaced[$match[0]])) { continue; }
$replaced[$match[0]] = true;
if ( !empty( $match[1] ) ) { $imagename = $match[2]; $component = rtrim($match[1], '|'); }
else {
if ( !empty( $match[2] ) )
}
$imageurl = $this->pix_url($imagename, $component)->out(false);
// we do not need full url because the image.php is always in the same dir
$imageurl = preg_replace('|^http.?://[^/]+|', '', $imageurl);
$css = str_replace($match[0], $imageurl, $css);
}
}
// now resolve all theme settings or do any other postprocessing
$csspostprocess = $this->csspostprocess;
if (function_exists($csspostprocess))
return $css;
}
hope i will help moodle))
- duplicates
-
MDL-23493 Support for including a font through theme CSS
-
- Closed
-