Images and thumbnails not showing with any themes

Images and thumbnails not showing with any themes

Julien Ledoux -
回帖数:16

Hey guys,

First of all, I like your work ! I've just started to try Moodle out today, and it's highly customizable and have tons of functionalities ready to use, I love it ! It might just perfectly fits my company expectations.

IMO, it just lack a bit of more user friendly i18n features for contents translations, but with a bit of experience, you still get the result you want.

Anyway, my concern here is about images such as logos, favicon and their thumbnails in the themes admin section, none of them are displayed on my test environment.

I've installed latest stable version 3.1.1 with latest php-fpm 5.6.24 and MySQL 5.6.32 running on Nginx 1.10.1 in Docker containers.

I've tried with themes Clean, More, Essential, Adaptable, Aardvark... It's always the same behaviour : when I want to upload an image (jpg in that case), lets say a logo for instance, everything seems to works fine, image is properly uploaded but after saving the form, thumbnail and image give a 404 error (I've attached some screenshots). Image is indeed uploaded because you can see its properties such as size and dimensions. Path might be the issue, I tried to debug it, but since I'm a noob with Moodle, I don't understand clearly how it's working.

I've also purged all caches a few times.

Image uploads works fine when I'm in profile section, as well as document upload.

I'd like to configure a demo version for my managers, but this issue is kind of a love killer, any help would be appreciated.


Thanks !

附件 Capture d’écran 2016-08-17 à 18.31.08.png
回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

Here is another screenshot

附件 Capture d’écran 2016-08-17 à 18.35.32.jpg
回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Server configuration / installation error somewhere.  Check core config.php with DNS entry etc.

回复Gareth J Barnard

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

Thanks for your answer.

I've a basic configuration, it's a brand new project, and I don't have any other issue with upload process in other sections.

I've only changed session management in order to use session files.

$CFG->session_handler_class  = '\core\session\file';
$CFG->session_file_save_path = sys_get_temp_dir();

Path and DNS seems fine to me, here are the 404 urls for the logo and its thumb :


http://moodle.dev/draftfile.php/5/user/draft/187123906/logo%20new.jpg?preview=thumb&oid=1471445097

And here is a working image url :

http://moodle.dev/pluginfile.php/5/user/icon/clean/f2?rev=48

What do you think ?

回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Mary Evans -

It sounds like a Moodle directory permissions problem. Normally this is not a problem, but has been known to be different on some servers. So you need to check those settings. Security

Cheers

Mary

回复Mary Evans

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

Thanks for your advice Mary, I've chmod 777 recursively the whole directories and files under my moodledata dir, uploaded logo again but still have the issue.

But I don't understand how could this be related to permissions when upload works with courses documents and profile avatar...

回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Mary Evans -

I do not know why it happens but we get this question a lot and the problems are all to do with server permissions or browser settings, and rarely anything to do with themes.

The fact this is not working in all themes tends to point to a server setting...or an admin setting...and also and just as important a browser setting.

It could also be the device you are using be it  a PC or MAC iPad, Android, whatever...

Try purging the cache Purge all cache

回复Mary Evans

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

I did purge all caches, but the issue still remains after re uploading logos.

回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Emma Richardson -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Did you change the website address at some point and is that change reflected in your config.php?  Is the web user owner of the folders?

回复Emma Richardson

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

I haven't changed the website address.

I checked again permissions and ownerships, and finally fixed this issue ! 

It was indeed related to my docker environment and the NFS mount I use to share files between volumes containers and the Mac osx host.

For those who might encounter the same issue here is the solution.

In docker-compose I've set application volume like this :

application:
        build: ./docker/storage-application
        image: application_image
        container_name: application_volume
        volumes:
            - ~/Sites/drupal-8.1.3/:/var/www/drupal8
            - ~/Sites/moodle/:/var/www/moodle

Then in storage-application's Dockerfile I used to set ownership directly on /var/www, that was causing the issue :

RUN \
    mkdir -p /var/www && \
    chown -R 1000:1000 /var/www

1000 is a numeric id associated with user 'www-data', it is created in php-fpm's Dockefiler with command 'RUN usermod -u 1000 www-data'

The thing is, /var/www is outside of the volume mount and chown -R will not be applied to mounted volumes underneath.

So in order to make this working, I had to apply ownership on each mounted volumes separately :

RUN \
    mkdir -p \
        /var/www/drupal8 \
        /var/www/moodle && \
    chown 1000:1000 \
        /var/www/drupal8 \
        /var/www/moodle

Thanks for pointing me in the right direction guys ! And keep doing a great job with moodle ;o)

(Apologies for my bad english, it is not my native language)

回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Mary Evans -

Ah...another coder hits the dust!!!

Well now you know how sensitive Moodle is you will think twice before asking another question! LOL

Cheers

Mary

回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Really useful Julien, thanks for the information.

Running Moodle on Docker was talked about at iMoot 2016.  I wonder if its worth adding to / creating a separate page in the docs -> Installing_Moodle?

Cheers,

Gareth

回复Gareth J Barnard

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

If you're interested, some people shared Moodle docker images, I haven't tried with those though :

https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=moodle&starCount=0

Maybe Moodle team can create an official docker repo ?

Cheers

回复Julien Ledoux

Re: Images and thumbnails not showing with any themes

Gareth J Barnard -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Are there any errors in the web server or PHP log files?

Is the moodle.dev URL the same in the config.php  browser URL line?

Have you tried statically serving a JPG file on the same site just in case of a mime type issue?

As the images are stored in the 'moodledata' folder, permissions on that an issue?

I've never run Moodle in a Docker container before (or the FPM version of PHP) so some of this is guess work.

回复Gareth J Barnard

Re: Images and thumbnails not showing with any themes

Julien Ledoux -

I don't see any errors related to this issue in error log file. I'll try to change php error level.

I do have moodle.dev as wwwroot in config.php :

$CFG->wwwroot   = 'http://moodle.dev';

I also have others various php projects running in the same docker configuration that have no images issues.

As I said before permissions in moodledata are 777 and www-data.

I've noticed that when I change my profile picture, thumbnail is not generated either, but the original image is properly displayed in my account.

I'm starting to think this issue might be related to gd library, it might just not be working as expected. I'll run some tests and let you know.