Skip to content
Browse files

MDL-22955 output: Added block to ensure that SVG is not used within CSS

  • Loading branch information...
1 parent 436dbee commit f7d6a556cf105f1c60a5d11356171afec2a7b3a1 Sam Hemelryk committed Oct 3, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/outputlib.php
View
16 lib/outputlib.php
@@ -948,6 +948,11 @@ public function javascript_content($type) {
public function post_process($css) {
// now resolve all image locations
if (preg_match_all('/\[\[pix:([a-z_]+\|)?([^\]]+)\]\]/', $css, $matches, PREG_SET_ORDER)) {
+ // We are going to disable the use of SVG images when available in CSS background-image properties
+ // as support for it in browsers is at best quirky.
+ // When we choose to support SVG in background css we will need to remove this code and implement a solution that is
+ // either consistent or varies the URL for serving CSS depending upon SVG being used if available, or not.
+ $this->force_svg_use(false);
$replaced = array();
foreach ($matches as $match) {
if (isset($replaced[$match[0]])) {
@@ -1132,6 +1137,17 @@ public function use_svg_icons() {
}
/**
+ * Forces the usesvg setting to either true or false, avoiding any decision making.
+ *
+ * This function should only ever be used when absolutely required, and before any generation of image URL's has occurred.
+ *
+ * @param bool $setting True to force the use of svg when available, null otherwise.
+ */
+ private function force_svg_use($setting) {
+ $this->usesvg = (bool)$setting;
+ }
+
+ /**
* Checks if file with any image extension exists.
*
* The order to these images was adjusted prior to the release of 2.4

0 comments on commit f7d6a55

Please sign in to comment.
Something went wrong with that request. Please try again.