Missing Images from a course - Moodle 3.11.5

Missing Images from a course - Moodle 3.11.5

- Dave Emsley の投稿
返信数: 5

Hi All,

I posted this in general a week or so ago but I think it's more specific than that.    I upgraded from Moodle 3.5 via 3.8 to Moodle 3.11 so I do not know if this might have caused it?

The issue is that when I view a course the images in the labels and section titles are not showing.  The URL showing in inspection for the blank files has the "?file=" part missing. If I manually add this in the inspector the image appears.  What is rendered is:


<p dir="ltr" id="yui_3_17_2_1_1642418323557_1527">
<b id="yui_3_17_2_1_1642418323557_1526">
<img src="https://mymoodleURL/pluginfile.php/3142/course/section/446/20201126_194835.jpg" alt=""
role="presentation" class="img-responsive atto_image_button_middle" id="yui_3_17_2_1_1642418323557_1525" width="400" height="230">
<br>
</b>
</p>
Which is all very confusing as I cannot see where the issue might be coming from.

Best Regards

Dave

Dave Emsley への返信

Missing Images from a course - Moodle 3.11.5

- Paul Holden の投稿
画像 Core developers 画像 Moodle HQ 画像 Moodle Workplace team 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers 画像 Testers
Hi Dave,

Check your site slash arguments settings, see: https://docs.moodle.org/311/en/Using_slash_arguments (including documentation on how to enable it for your server)
Paul Holden への返信

Re: Missing Images from a course - Moodle 3.11.5

- Dave Emsley の投稿
Hi Paul,

Thanks for that. Slash arguements are disabled in the site config.php file. I've tried setting it to true but this then broke the CSS. I'm looking into this now but it is hosted with IONOS which I have a feeling is part of the problem.

Cheers

Dave
Dave Emsley への返信

Re: Missing Images from a course - Moodle 3.11.5

- Dave Emsley の投稿
Dave Emsley への返信

Re: Missing Images from a course - Moodle 3.11.5

- Dave Emsley の投稿
This is now solved using the link above.

It is worth noting that copying and pasting the code from the above link doesn't work straight away as, for me at least, some of the comments and code lines merged. The only changes are to the function get_file_arguements from line 1120 approx.

This is the code I used, from
https://diocesanos-es.translate.goog/blogs/equipotic/2021/01/02/actualizado-moodle-a-v3-10-en-servidor-de-1and1-ionos/?_x_tr_sl=es&_x_tr_tl=en&_x_tr_hl=en-GB&_x_tr_pto=wapp
 
I hope it helps.


////////////////////////////////////////////////////////////////////////////////
/**
 * Extracts file argument either from file parameter or PATH_INFO
 *
 * Note: $scriptname parameter is not needed anymore
 *
 * @return string file path (only safe characters)
 *
 * Edited by DEmsley due to slash arguements not being available from Ionos.
 * 19/01/22
 * 
 */
function get_file_argument() {
    global $SCRIPT;
    $relativepath = false;
    $hasforcedslashargs = false;
    $pathinfo = ''; if (isset($_SERVER['PATH_INFO'])) { $pathinfo = $_SERVER['PATH_INFO']; } 
else if (isset($_SERVER['ORIG_PATH_INFO'])) { $pathinfo = $_SERVER['ORIG_PATH_INFO'];
}
if (isset($_SERVER['REQUEST_URI']) && !empty($_SERVER['REQUEST_URI'])) { // Checks whether $_SERVER['REQUEST_URI'] contains '/pluginfile.php/' // instead of '/pluginfile.php?', when serving a file from e.g. mod_imscp or mod_scorm. if ((strpos($_SERVER['REQUEST_URI'], '/pluginfile.php/') !== false) && !empty($pathinfo)) { // Exclude edge cases like '/pluginfile.php/?file='. $args = explode('/', ltrim($pathinfo, '/')); $hasforcedslashargs = (count($args) > 2); // Always at least: context, component and filearea. } } if (!$hasforcedslashargs) { $relativepath = optional_param('file', false, PARAM_PATH); }
if ($relativepath !== false and $relativepath !== '') { return $relativepath; } $relativepath = false;
// Then try extract file from the slasharguments. if (stripos($_SERVER['SERVER_SOFTWARE'], 'iis') !== false) { // NOTE: IIS tends to convert all file paths to single byte DOS encoding, // we can not use other methods because they break unicode chars, // the only ways are to use URL rewriting // OR // to properly set the 'FastCGIUtf8ServerVariables' registry key. if ($pathinfo !== '') { // Check that PATH_INFO works == must not contain the script name. if (strpos($pathinfo, $SCRIPT) === false) { $relativepath = clean_param(urldecode($pathinfo), PARAM_PATH); } } } else { // All other apache-like servers depend on PATH_INFO. if ($pathinfo !== '') { if (isset($_SERVER['SCRIPT_NAME']) and strpos($pathinfo, $_SERVER['SCRIPT_NAME']) === 0) { $relativepath = substr($pathinfo, strlen($_SERVER['SCRIPT_NAME']));
} else { $relativepath = $pathinfo;
} $relativepath = clean_param($relativepath, PARAM_PATH); } }
return $relativepath; } //////////////////////////////////////////////////////////////////////////
Dave Emsley への返信

Re: Missing Images from a course - Moodle 3.11.5

- AL Rachels の投稿
画像 Core developers 画像 Particularly helpful Moodlers 画像 Plugin developers 画像 Testers
I sympathize as I currently have four Moodle sites on IONOS, started back when they were 1and1, and all four have to use disabled slash arguments. Another upcoming problem with IONOS is I have not been able to get Moodle 4.0 development code to even install due to only having access to a homepages/xx/xxxx/htdocs folder.