original_string: public function resolve_image_location($image, $component, $svg = false) {
          global $CFG;
  
          if (!is_bool($svg)) {
              // If $svg isn't a bool then we need to decide for ourselves.
              $svg = $this->use_svg_icons();
          }
  
          if ($component === 'moodle' or $component === 'core' or empty($component)) {
              if ($imagefile = $this->image_exists("$this->dir/pix_core/$image", $svg)) {
                  return $imagefile;
              }
              foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                  if ($imagefile = $this->image_exists("$parent_config->dir/pix_core/$image", $svg)) {
                      return $imagefile;
                  }
              }
              if ($imagefile = $this->image_exists("$CFG->dataroot/pix/$image", $svg)) {
                  return $imagefile;
              }
              if ($imagefile = $this->image_exists("$CFG->dirroot/pix/$image", $svg)) {
                  return $imagefile;
              }
              return null;
  
          } else if ($component === 'theme') { //exception
              if ($image === 'favicon') {
                  return "$this->dir/pix/favicon.ico";
              }
              if ($imagefile = $this->image_exists("$this->dir/pix/$image", $svg)) {
                  return $imagefile;
              }
              foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                  if ($imagefile = $this->image_exists("$parent_config->dir/pix/$image", $svg)) {
                      return $imagefile;
                  }
              }
              return null;
  
          } else {
              if (strpos($component, '_') === false) {
                  $component = 'mod_'.$component;
              }
              list($type, $plugin) = explode('_', $component, 2);
  
              if ($imagefile = $this->image_exists("$this->dir/pix_plugins/$type/$plugin/$image", $svg)) {
                  return $imagefile;
              }
              foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                  if ($imagefile = $this->image_exists("$parent_config->dir/pix_plugins/$type/$plugin/$image", $svg)) {
                      return $imagefile;
                  }
              }
              if ($imagefile = $this->image_exists("$CFG->dataroot/pix_plugins/$type/$plugin/$image", $svg)) {
                  return $imagefile;
              }
              $dir = core_component::get_plugin_directory($type, $plugin);
              if ($imagefile = $this->image_exists("$dir/pix/$image", $svg)) {
                  return $imagefile;
              }
              return null;
          }
      }
code: public function resolve_image_location($image, $component, $svg = false) {
          global $CFG;
  
          if (!is_bool($svg)) {
              // If $svg isn't a bool then we need to decide for ourselves.
              $svg = $this->use_svg_icons();
          }
  
          if ($component === 'moodle' or $component === 'core' or empty($component)) {
              if ($imagefile = $this->image_exists("$this->dir/pix_core/$image", $svg)) {
                  return $imagefile;
              }
              foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                  if ($imagefile = $this->image_exists("$parent_config->dir/pix_core/$image", $svg)) {
                      return $imagefile;
                  }
              }
              if ($imagefile = $this->image_exists("$CFG->dataroot/pix/$image", $svg)) {
                  return $imagefile;
              }
              if ($imagefile = $this->image_exists("$CFG->dirroot/pix/$image", $svg)) {
                  return $imagefile;
              }
              return null;
  
          } else if ($component === 'theme') { //exception
              if ($image === 'favicon') {
                  return "$this->dir/pix/favicon.ico";
              }
              if ($imagefile = $this->image_exists("$this->dir/pix/$image", $svg)) {
                  return $imagefile;
              }
              foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                  if ($imagefile = $this->image_exists("$parent_config->dir/pix/$image", $svg)) {
                      return $imagefile;
                  }
              }
              return null;
  
          } else {
              if (strpos($component, '_') === false) {
                  $component = 'mod_'.$component;
              }
              list($type, $plugin) = explode('_', $component, 2);
  
              if ($imagefile = $this->image_exists("$this->dir/pix_plugins/$type/$plugin/$image", $svg)) {
                  return $imagefile;
              }
              foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                  if ($imagefile = $this->image_exists("$parent_config->dir/pix_plugins/$type/$plugin/$image", $svg)) {
                      return $imagefile;
                  }
              }
              if ($imagefile = $this->image_exists("$CFG->dataroot/pix_plugins/$type/$plugin/$image", $svg)) {
                  return $imagefile;
              }
              $dir = core_component::get_plugin_directory($type, $plugin);
              if ($imagefile = $this->image_exists("$dir/pix/$image", $svg)) {
                  return $imagefile;
              }
              return null;
          }
      }
code_tokens: public function resolve_image_location ( $ image , $ component , $ svg = false ) { global $ CFG ; if ( ! is_bool ( $ svg ) ) { // If $svg isn't a bool then we need to decide for ourselves. $ svg = $ this -> use_svg_icons ( ) ; } if ( $ component === 'moodle' or $ component === 'core' or empty ( $ component ) ) { if ( $ imagefile = $ this -> image_exists ( "$this->dir/pix_core/$image" , $ svg ) ) { return $ imagefile ; } foreach ( array_reverse ( $ this -> parent_configs ) as $ parent_config ) { // base first, the immediate parent last if ( $ imagefile = $ this -> image_exists ( "$parent_config->dir/pix_core/$image" , $ svg ) ) { return $ imagefile ; } } if ( $ imagefile = $ this -> image_exists ( "$CFG->dataroot/pix/$image" , $ svg ) ) { return $ imagefile ; } if ( $ imagefile = $ this -> image_exists ( "$CFG->dirroot/pix/$image" , $ svg ) ) { return $ imagefile ; } return null ; } else if ( $ component === 'theme' ) { //exception if ( $ image === 'favicon' ) { return "$this->dir/pix/favicon.ico" ; } if ( $ imagefile = $ this -> image_exists ( "$this->dir/pix/$image" , $ svg ) ) { return $ imagefile ; } foreach ( array_reverse ( $ this -> parent_configs ) as $ parent_config ) { // base first, the immediate parent last if ( $ imagefile = $ this -> image_exists ( "$parent_config->dir/pix/$image" , $ svg ) ) { return $ imagefile ; } } return null ; } else { if ( strpos ( $ component , '_' ) === false ) { $ component = 'mod_' . $ component ; } list ( $ type , $ plugin ) = explode ( '_' , $ component , 2 ) ; if ( $ imagefile = $ this -> image_exists ( "$this->dir/pix_plugins/$type/$plugin/$image" , $ svg ) ) { return $ imagefile ; } foreach ( array_reverse ( $ this -> parent_configs ) as $ parent_config ) { // base first, the immediate parent last if ( $ imagefile = $ this -> image_exists ( "$parent_config->dir/pix_plugins/$type/$plugin/$image" , $ svg ) ) { return $ imagefile ; } } if ( $ imagefile = $ this -> image_exists ( "$CFG->dataroot/pix_plugins/$type/$plugin/$image" , $ svg ) ) { return $ imagefile ; } $ dir = core_component :: get_plugin_directory ( $ type , $ plugin ) ; if ( $ imagefile = $ this -> image_exists ( "$dir/pix/$image" , $ svg ) ) { return $ imagefile ; } return null ; } }
docstring: Resolves the real image location.
  
  $svg was introduced as an arg in 2.4. It is important because not all supported browsers support the use of SVG
  and we need a way in which to turn it off.
  By default SVG won't be used unless asked for. This is done for two reasons:
  1. It ensures that we don't serve svg images unless we really want to. The admin has selected to force them, of the users
  browser supports SVG.
  2. We only serve SVG images from locations we trust. This must NOT include any areas where the image may have been uploaded
  by the user due to security concerns.
  
  @param string $image name of image, may contain relative path
  @param string $component
  @param bool $svg|null Should SVG images also be looked for? If null, resorts to $CFG->svgicons if that is set; falls back to
  auto-detection of browser support otherwise
  @return string full file path
docstring_tokens: Resolves the real image location .