I am busy creating my 4th Custom Module for my own use. I use PhpStorm for the php dev on Gentoo Linux
I have done this before on my other modules, but images not showing on this one!! I have some text and display two CSV files in tables which all shows fine on the page. Looking at the page source, the <img src="...> element is there
here is some of the code for the markup
$basefolder = BACKDROP_ROOT . '/files/met/seaiceArchiveSummary/';
$uri_nhmin = $basefolder . 'NH_Min2019_small.png';
$build[] = array( '#theme' => 'image', '#uri' => $uri_nhmin, );
When I look at the variable $uri_nhchart I know it is correct because I can copy it and do this in a terminal
ls /PATH/TO/FILE/NH_Min2019_small.png
and the file is there.
Also no errors in the site logs. as per the access log gives an http 200 code:
"GET /home/francis/FG-Docs/public_html/moduledev.bd/web/files/met/seaiceArchiveSummary/NH_Min2019_small.png HTTP/1.1" 200
For anyone also having a problem.......
I think I have worked out the answer after a lot of looking in the logs and stepping through the module. It is all to do with mixing System Paths and Website Paths
My BACKDROP_ROOT is in the 'web' folder of the Site.
To display an image you have to use the $basefolder as below with the following
NOT with this:
So when you try to create the image using this:
Your path would look like this in $uri_nhmin
Now if you then try and use glob to get a list of files, you have to use a System Path, not a Website Path, then use the basename() to get the filename and then append it to the $basefolder so the #uri is a Web Path, not a System Path..
I should have known this, but it had escaped me today for some reason.