Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-22955

Add support for SVG images to the image system within Moodle 2

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.4
    • Component/s: Themes
    • Labels:
      None
    • Testing Instructions:
      Hide

      1. Run the unit tests, particularly lib/tests/outputlib_test.php

      2. Copy the following code into a test script in the root of your Moodle directory:

      <?php
      require_once('config.php');
      $PAGE->set_context(context_system::instance());
      $PAGE->set_url('/');
      echo $OUTPUT->pix_icon('i/test', 'You should never see this');

      3. Test this code in all of the supported browsers. In IE8 (or any earlier version) you should get a blue ball. In all other browsers you should get an orange ball.

      4. Test the order of image caching

      • Using IE8:
      • Turn off theme designer mode.
      • Purge the site caches
      • Visit the test script and make sure you see a blue ball.
      • Switch to Firefox or Chrome
      • Visit the test script and check you see an orange ball.
      • Switch back to IE8
      • Enable theme designer mode
      • Visit the test script and make sure you see a blue ball.
      • Switch to Firefox or Chrome
      • Visit the test script and check you see an orange ball.

      5. Test CSS

      • Edit theme/base/styles/admin.css
      • Add the following to the bottom: #sams-svg-test {background-image:url([[pix:core|i/test]]);}
      • Using Firefox or Chrome
      • Purge your caches
      • Using the dev toolkit (firebug or dev tools) find the admin CSS file contents. If you have theme designer mode on it will be a separate sheet, otherwise it will be a sheet called all.
      • Search the CSS for #sams-svg-test
      • Check that the URL either contains /_s/ if theme designer mode off or svg=0 if theme designer mode is on.
      Show
      1. Run the unit tests, particularly lib/tests/outputlib_test.php 2. Copy the following code into a test script in the root of your Moodle directory: <?php require_once('config.php'); $PAGE->set_context(context_system::instance()); $PAGE->set_url('/'); echo $OUTPUT->pix_icon('i/test', 'You should never see this'); 3. Test this code in all of the supported browsers. In IE8 (or any earlier version) you should get a blue ball. In all other browsers you should get an orange ball. 4. Test the order of image caching Using IE8: Turn off theme designer mode. Purge the site caches Visit the test script and make sure you see a blue ball. Switch to Firefox or Chrome Visit the test script and check you see an orange ball. Switch back to IE8 Enable theme designer mode Visit the test script and make sure you see a blue ball. Switch to Firefox or Chrome Visit the test script and check you see an orange ball. 5. Test CSS Edit theme/base/styles/admin.css Add the following to the bottom: #sams-svg-test {background-image:url([[pix:core|i/test]]);} Using Firefox or Chrome Purge your caches Using the dev toolkit (firebug or dev tools) find the admin CSS file contents. If you have theme designer mode on it will be a separate sheet, otherwise it will be a sheet called all. Search the CSS for #sams-svg-test Check that the URL either contains /_s/ if theme designer mode off or svg=0 if theme designer mode is on.
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE
    • Pull Master Branch:
      wip-MDL-22955-m24

      Description

      Hi guys,

      The order of file extension Moodle searches when locating an image was discussed in the forum not so long ago and the question was raised about why SVG was not on the list.
      I've created this issue because I think it would be a great idea to add support for using SVG images, particularly so themer's can override core images with SVG's.

      I purpose to prepend SVG to the list of image formats that Moodle searches for unless the user is using IE < 9 (they've finally added SVG support in IE 9). This would of course make SVG the first format searched for which is probably fine given that it won't be used if the users browser doesn't support it.

      Before I produce a patch or anything I would like to get some feedback from people about this.

      Cheers
      sam

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    3/Dec/12