Skip to content

Commit cdb82da

Browse files
committed
Add help text to set as index image and fix its caching
Without this, the intent of the button is unclear. The image cached on the gallery index page is also not updated when a new image is selected as the index without the mtime provided by this change.
1 parent 7aa7602 commit cdb82da

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

edit/thumbnail/thumbnail.class.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,14 @@ public function __construct($gallery, $cm, $image, $tab) {
4242
* @throws coding_exception
4343
*/
4444
public function output() {
45+
global $OUTPUT;
46+
47+
$url = new moodle_url('/mod/lightboxgallery/index.php', ['id' => $this->gallery->course]);
48+
$helpbutton = $OUTPUT->help_icon('setasindex', 'lightboxgallery', true, $url);
4549
$result = '<input type="submit" class="btn btn-secondary" name="index" value="' .
46-
get_string('setasindex', 'lightboxgallery') . '" /><br /><br />' .
50+
get_string('setasindex', 'lightboxgallery') . '" />'.$helpbutton;
51+
52+
$result .= '<br /><br />' .
4753
get_string('selectthumbpos', 'lightboxgallery') . '<br /><br />';
4854

4955
if ($this->lbgimage->width < $this->lbgimage->height) {

lang/en/lightboxgallery.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
$string['selectrotation'] = 'Select rotation angle';
139139
$string['selectthumbpos'] = 'Thumbnail offset (from centre)';
140140
$string['setasindex'] = 'Set as index image';
141+
$string['setasindex_help'] = 'Selecting this sets this image as the primary image shown on the <a href="{$a}">list of lightbox galleries</a> in this course.';
141142
$string['showall'] = 'Show all';
142143
$string['sortby'] = 'Sort by';
143144
$string['sortby_help'] = 'How to sort the order the images are displayed in.';

locallib.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,15 @@ function lightboxgallery_index_thumbnail($courseid, $gallery, $newimage = null)
248248
];
249249
$index = $fs->create_file_from_pathname($fileinfo, $CFG->dirroot . '/mod/lightboxgallery/pix/index.png');
250250
}
251-
$path = $CFG->wwwroot.'/pluginfile.php/'.$context->id.'/mod_lightboxgallery/gallery_index/'.
252-
$index->get_itemid().$index->get_filepath().$index->get_filename();
251+
252+
$path = moodle_url::make_pluginfile_url($context->id,
253+
'mod_lightboxgallery',
254+
'gallery_index',
255+
$index->get_itemid(),
256+
$index->get_filepath(),
257+
$index->get_filename(),
258+
);
259+
$path->param('mtime', $index->get_timemodified());
253260

254261
return '<img src="' . $path . '" alt="" ' . (! empty($imageid) ? 'id="' . $imageid . '"' : '' ) . ' />';
255262
}

0 commit comments

Comments
 (0)