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

Unable to reference images through template context in Moodle 4.5

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • 4.5.1
    • Themes
    • None
    • MOODLE_405_STABLE

      I'm upgrading a Moodle custom theme based on Boost from an early Moodle4 version. This theme uses an image in the footer that was previously referenced using:

      $templatecontext = [
      'image1' => $OUTPUT->image_url('image1’, 'theme'),
      ];

      Where image1 is in the root of the pix directory and the filename is image1.png.

      In the updated documentation (https://moodledev.io/docs/4.5/apis/plugintypes/theme/images) it looks like the the way to reference this image in the template context has changed to

      $templatecontext = [
      $image1 => $OUTPUT->pix_url('image1’, 'theme'),
      ];

      But this doesn't work form me, unless I'm missing a step. As far as I know nothing else has changed. To work around this I ended up referencing the image directly in the template without using the context as follows:

      <img src="config.wwwroot/theme/my_theme/pix/image1.png" alt="My image">

      Can someone confirm if the new template context reference works as documented?

       

       

            Unassigned Unassigned
            namscott Natasha Scott
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.