Get the thumnail of the image 200*200 pixels...
Get json error
Mutualized server 1and 1...
I tryed to add thumbnails settings in database like in issue https://github.com/directus/api/issues/469, but it doesn't change
Note: Also when I insert an image in my files, thumbnails throw error (404 not found in console)
master branch from api 2.0.2 and app 7.0.2 separately]Hello, check src\web.php line 28.
Problem is that Directus try to find a project with name "uploads"
https://api....com/uploads/_/originals/Jellyfish-1.jp - ok
but change
https://api....com/uploads/_/thumbnails/200/200/crop/good/Chrysanthemum.jpg
to
https://api....com/thumbnail/_/200/200/crop/good/Chrysanthemum.jpg
https://api....com/uploads/_/thumbnails/200/200/crop/good/Chrysanthemum.jpg also works, but only if a thumbnail already exists. (because .htaccess -> RewriteCond %{REQUEST_FILENAME} !-f)
It is a little confusing.
Or log in. Go to File Library -> F12 -> Network -> Img -> F5 and you can see urls for thumbs.
Hey @fecou, where this url returned by the API? the thumbnailer url format is different. You can take a look at the url format here: https://github.com/directus/docs/blob/master/api/admin/thumbnailer.md#url-syntax
Hello,
Thank you for your answers. I understand what yo mean.
But it still doesnt work with https://api....com/thumbnail/_/200/200/crop/good/Chrysanthemum.jpg
If, as @benhaynes said, I go to files I see a 404 error on the loading of my images. So it's not about the url I use. It might be a misconfiguration, if I am the only one to face this issue...
I'm facing a similar issue (if not the very same). Thumbnails are nowhere to be found in the app interface and I'm not sure how to query the API directly so I can have an idea of what's going on.
EDIT: I just realized it can be due to me running Directus within official docker images (whitelist related). I'm going to investigate down this road.
OK, my problem may be that dockerized version of Directus is running with nginx, thus bypassing the .htaccess altogether (I'm referring to to the page linked by @WellingGuzman above)
Further investigation led me to this.
Request: GET http://<myhost>/thumbnail/_/100/100/crop/poor/bandb-bg.jpg
Response: 404 with the following JSON body:
{
"error" : {
"error" : 8,
"message" : "API Environment Configuration Not Found: thumbnail"
}
}
It seems the PHP script is invoked correctly but something similar to the main issue happens, only at a different level.
Also tried with http://<myhost>/thumbnail/<project_name>/100/100/crop/poor/bandb-bg.jpg
@stickgrinder that's the issue here, we need to create a new location block to catch the /thumbnail request.
Try something like this in your api nginx config:
location /thumbnail {
rewrite /thumbnail/(.*) /thumbnail/index.php last;
}
Let me know if that works for you.
I tried that stuff but as I said on slack, I'm not an nginx ninja and I made a mistake, it seams!
I'm going to test it out, thanks!
Actually it doesn't seem to work... I'll try to understand which kind of call the File Library is making to retrieve images since the console is not helping me at all.
@stickgrinder how does your nginx configuration looks like? it seems that the problem is actually the missing location in your nginx configuration. it should be almost the same as your / location block, but with /thumbnail in the front.
@WellingGuzman here it is
server {
listen 80;
server_name _;
root /var/www/html/public;
index index.php index.html index.htm;
gzip on;
sendfile on;
keepalive_timeout 60;
default_type application/octet-stream;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /thumbnail/ {
rewrite /thumbnail/(.*) /thumbnail/index.php last;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
fastcgi_param DOCUMENT_ROOT /var/www/html/public/;
internal;
}
location ~ /\.ht {
deny all;
}
}
I reloaded nginx configuration (nginx -s reload) but nothing changes.
I have the same problem if I run the Docker version on a fresh install.
@WellingGuzman I decided to file my progress on the thumbnail problem with nginx where it belongs (directus/docker): https://github.com/directus/docker/issues/10#issuecomment-444782346, just in case you feel like following up the discussion.
Thanks a lot!
I have also a problem with that.
I figure out that '$this->getConfig()' will return a array with the needed entry 'thumbnail_demensions' but the 'ArrayUtils' can't get them. The 'ArrayUtils' return NULL but not the configured settings.
/**
* Return supported thumbnail file dimesions
*
* @return array
*/
public function getSupportedThumbnailDimensions()
{
$defaultDimension = '200x200';
// returns NULL
$dimensions = $this->parseCSV(
ArrayUtils::get($this->getConfig(), 'thumbnail_dimensions')
);
if (!in_array($defaultDimension, $dimensions)) {
array_unshift($dimensions, $defaultDimension);
}
return $dimensions;
}
In this example I get the integer key of 'thumbnail_demensions' and in the next step I get the value of this key
/**
* Return supported thumbnail file dimesions
*
* @return array
*/
public function getSupportedThumbnailDimensions()
{
$defaultDimension = '200x200';
$key = array_search('thumbnail_dimensions', array_column($this->getConfig(), 'key'));
$dimensions = $this->parseCSV(
$this->getConfig()[$key]['value']
);
if (!in_array($defaultDimension, $dimensions)) {
array_unshift($dimensions, $defaultDimension);
}
return $dimensions;
}
So I think the ArrayUtils didn't work correctly or the '$this->getConfig()' will return an incorrect array.
Hey @rjwismar, there was a bug in the get_directus_thumbnail_settings (https://github.com/directus/api/blob/master/public/thumbnail/index.php#L26) function that return the the settings as a numeric index list, instead of a key-value array.
It was fixed by https://github.com/directus/api/commit/288503e7c4892e349e9798d657e0cba49b5e265d
This was fixed by https://github.com/directus/api/commit/288503e7c4892e349e9798d657e0cba49b5e265d. Due to inactivity I believe this confirm the fix, and I am closing this ticket.
if there's problem with the thumbnailer getting 404, please let me know and I will reopen this ticket.
Most helpful comment
OK, my problem may be that dockerized version of Directus is running with nginx, thus bypassing the .htaccess altogether (I'm referring to to the page linked by @WellingGuzman above)