Skip to content

Commit ec60b6f

Browse files
author
cbadusch
committed
Bugfix: resolve image URLs against wwwroot on sub-directory installs #459 #460
1 parent fb5d4a7 commit ec60b6f

12 files changed

Lines changed: 98 additions & 13 deletions

File tree

classes/asset_handler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public static function get_image_paths() {
6060
$path = $CFG->dirroot . '/local/adele/public/' . $pathorigin . '/*';
6161
$filelist = glob($path);
6262
foreach ($filelist as $file) {
63-
$filepath[$pathorigin][] = [ 'path' => str_replace($CFG->dirroot, '', $file)];
63+
// Absolute URL (like the uploaded pluginfile URLs below): a root-relative
64+
// path 404s on sub-directory installs, e.g. localhost/moodle03 (#459).
65+
$filepath[$pathorigin][] = [ 'path' => $CFG->wwwroot . str_replace($CFG->dirroot, '', $file)];
6466
}
6567
}
6668
// Get uploaded images from mdl_files.

vue3/components/LearningPathList.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
class="mb-2"
8989
:style="{
9090
height: '10rem',
91-
backgroundImage: singlelearningpath.image ? `url(${singlelearningpath.image})` : '',
91+
backgroundImage: singlelearningpath.image ? `url(${absUrl(singlelearningpath.image, store.state.wwwroot)})` : '',
9292
backgroundSize: 'cover',
9393
backgroundPosition: 'center',
9494
backgroundColor: '#cccccc',
@@ -213,7 +213,7 @@
213213
class="mb-2"
214214
:style="{
215215
height: '10rem',
216-
backgroundImage: viewablelearningpath.image ? `url(${viewablelearningpath.image})` : '',
216+
backgroundImage: viewablelearningpath.image ? `url(${absUrl(viewablelearningpath.image, store.state.wwwroot)})` : '',
217217
backgroundSize: 'cover',
218218
backgroundPosition: 'center',
219219
backgroundColor: '#cccccc',
@@ -260,6 +260,7 @@
260260
<script setup>
261261
// Import needed libraries
262262
import { computed, ref, watch, onMounted, } from 'vue'
263+
import absUrl from '../composables/absUrl';
263264
import { useStore } from 'vuex'
264265
import { useRouter } from 'vue-router';
265266
import { notify } from "@kyvg/vue3-notification"

vue3/components/charthelper/textInputs.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
22
import { ref, watch, onMounted } from 'vue';
3+
import absUrl from '../../composables/absUrl';
34
import { notify } from "@kyvg/vue3-notification";
45
import { useStore } from 'vuex'
56
import userSearch from './userSearch.vue';
@@ -190,7 +191,7 @@ const editLearningpath = async (singlelearningpathid) => {
190191
class="image-preview-container"
191192
>
192193
<img
193-
:src="selectedCourseImagePath"
194+
:src="absUrl(selectedCourseImagePath, store.state.wwwroot)"
194195
alt="Selected Image"
195196
class="image-preview"
196197
>

vue3/components/modals/HelpingSlider.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ import { useStore } from 'vuex';
226226
const store = useStore();
227227
const s = computed(() => store.state.strings);
228228
229-
const imageBase = '/local/adele/public/tutorial/';
229+
// Prefix with the Moodle root URL so the images resolve on sub-directory installs
230+
// (e.g. localhost/moodle03/...); a root-relative path 404s there and the flex
231+
// containers collapse to zero height (GitHub #460 tester feedback).
232+
const imageBase = store.state.wwwroot + '/local/adele/public/tutorial/';
230233
231234
// Each step: which part it belongs to, the screenshot, caption string keys and
232235
// the markers (position in % of the image plus a label string key).

vue3/components/modals/ModalNode.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
class="image-preview-container"
140140
>
141141
<img
142-
:src="selectedCourseImagePath"
142+
:src="absUrl(selectedCourseImagePath, store.state.wwwroot)"
143143
alt="Selected Image"
144144
class="image-preview"
145145
>
@@ -180,7 +180,7 @@
180180
class="image-preview-container"
181181
>
182182
<img
183-
:src="previewImage"
183+
:src="absUrl(previewImage, store.state.wwwroot)"
184184
alt="Selected Image"
185185
class="image-preview"
186186
>
@@ -219,6 +219,7 @@
219219
<script setup>
220220
// import dependancies
221221
import { useStore } from 'vuex'
222+
import absUrl from '../../composables/absUrl';
222223
import { onMounted, ref, watch, computed } from 'vue';
223224
224225
// define constants

vue3/components/nodes/CustomNode.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<script setup>
2626
// Import needed libraries
2727
import { Handle, Position } from '@vue-flow/core'
28+
import absUrl from '../../composables/absUrl';
2829
import { computed, onMounted, ref } from 'vue';
2930
import { useStore } from 'vuex';
3031
import NodeInformation from '../nodes_items/NodeInformation.vue';
@@ -74,7 +75,7 @@ const learningmodule = computed(() => {
7475
}
7576
return {};
7677
});
77-
const cover_image = computed(() => get_cover_image(props.data));
78+
const cover_image = computed(() => absUrl(get_cover_image(props.data), store.state.wwwroot));
7879
7980
onMounted(() => {
8081
dataValue.value = props.data

vue3/components/nodes/CustomNodeEdit.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<script setup>
2626
// Import needed libraries
2727
import { Handle, Position } from '@vue-flow/core'
28+
import absUrl from '../../composables/absUrl';
2829
import { computed, ref, onMounted } from 'vue';
2930
import { useStore } from 'vuex';
3031
import CompletionOutPutItem from '../completion/CompletionOutPutItem.vue'
@@ -185,7 +186,7 @@ const zoomOnParent = (payload = {}) => {
185186
}
186187
emit('zoomOnParent', {});
187188
}
188-
const cover_image = computed(() => get_cover_image(props.data));
189+
const cover_image = computed(() => absUrl(get_cover_image(props.data), store.state.wwwroot));
189190
190191
const get_cover_image = (data) => {
191192
if (data.selected_course_image) {
@@ -297,7 +298,7 @@ const courseLinkTitle = computed(() =>
297298
<button class="icon-link" :title="courseLinkTitle" @click="goToCourse">
298299
<div
299300
:class="{ 'icon-with-ring': hasTimedCondition }"
300-
:style="hasTimedCondition ? { backgroundImage: 'url(/local/adele/public/ring.png)' } : {}"
301+
:style="hasTimedCondition ? { backgroundImage: 'url(' + store.state.wwwroot + '/local/adele/public/ring.png)' } : {}"
301302
>
302303
<i :class="['fa', iconClass,
303304
{

vue3/components/nodes/CustomStagNodeEdit.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup>
22
// Import needed libraries
33
import { Handle, Position } from '@vue-flow/core'
4+
import absUrl from '../../composables/absUrl';
45
import { computed, ref, onMounted } from 'vue'
56
import { useStore } from 'vuex'
67
import CompletionOutPutItem from '../completion/CompletionOutPutItem.vue'
@@ -20,7 +21,7 @@ const store = useStore();
2021
const date = ref({})
2122
const progress = ref(0);
2223
23-
const cover_image = computed(() => get_cover_image(props.data));
24+
const cover_image = computed(() => absUrl(get_cover_image(props.data), store.state.wwwroot));
2425
2526
const get_cover_image = (data) => {
2627
if (data.selected_course_image) {

vue3/components/nodes/ExpandNodeEdit.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<script setup>
2626
// Import needed libraries
2727
import { computed, onMounted } from 'vue';
28+
import absUrl from '../../composables/absUrl';
2829
import { useStore } from 'vuex';
2930
import ExpandNodeInformation from '../nodes_items/ExpandNodeInformation.vue';
3031
import * as nodeColors from '../../config/nodeColors';
@@ -48,7 +49,7 @@ const goToCourse = () => {
4849
window.open(course_link, '_blank');
4950
}
5051
51-
const cover_image = computed(() => get_cover_image(props.data));
52+
const cover_image = computed(() => absUrl(get_cover_image(props.data), store.state.wwwroot));
5253
5354
const get_cover_image = (data) => {
5455
if (data.imagepaths && data.imagepaths[props.data.course_id]) {

vue3/components/nodes/OrCourses.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<script setup>
2626
// Import needed libraries
2727
import { Handle, Position } from '@vue-flow/core'
28+
import absUrl from '../../composables/absUrl';
2829
import { useStore } from 'vuex';
2930
import { computed, onMounted, ref } from 'vue';
3031
import ProgressBar from '../nodes_items/ProgressBar.vue';
@@ -78,7 +79,7 @@ const learningmodule = computed(() => {
7879
? parsedLearningModule.modules
7980
: {};
8081
});
81-
const cover_image = computed(() => get_cover_image(props.data));
82+
const cover_image = computed(() => absUrl(get_cover_image(props.data), store.state.wwwroot));
8283
8384
const props = defineProps({
8485
data: {

0 commit comments

Comments
 (0)