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

Make image requests automatically search theme, parent themes, then root pix folders

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8
    • Component/s: Themes
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE

      Description

      It is a pain to duplicate the pix folder in each theme.

      We coded a simple PHP script that searches for images in the appropriate order (theme, parent theme, root /pix). The script was designed for performance so it doesn't include the moodle config.php (it does do a nasty job of parsing the file to get dirroot), makes no database requests at all, and doesn't start a session [sessions prevent parallelism].

      This script is then used by putting its path into $CFG->pixpath and relying on php path information.

      To turn this on, you set $CFG->smartpix=1 manually in the database. I haven't provided interface to turn this on, as it should probably in future be set to always on (if it works) rather than a config option. So for now it is experimental for sites that really want it.

      When using this script I noticed a slight performance decrease (i.e. you can see icons loading down the page) when Ctrl-Shift-Reloading a page. Since images are cached - I set expiry to 4 hours - this does not make a difference within a session of browsing the site. If-Modified-Since is also supported, so this causes relatively few problems even between sessions. I did test the script to ensure that two instances can run concurrently; they can.

      The script isn't compatible with changes to themedir (etc) but if you change themedir it's probably so you can put it on another server or something like that for performance reasons, which this system wouldn't handle anyway.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              quen Sam Marshall
              Reporter:
              quen Sam Marshall
              Tester:
              Nobody
              Participants:
              Component watchers:
              Bas Brands
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                31/Mar/07