- Главная
- Блоги
- Блог shumod@drupal.org
Ошибка генерации изображения
Главные вкладки
- Просмотр(активная вкладка)
- Реакции
Не могу понять в чём дело. Не создаются превьюшки картинок.
При попытке зайти по прямой ссылке на превью пишет «Ошибка генерации изображения». Подскажите, в чём может быть дело?
- Drupal7
- Есть вопрос
- Блог
- Войдите или зарегистрируйтесь, чтобы отправлять комментарии
Комментарии
skit25
4 сентября 2012 в 19:38
лес рук
Тоже внезапно напала такая проблема, пока не решил. Все обновил, крон, кэш…
GotLosiom
10 сентября 2012 в 0:02
Стоит проверить:
1. Пути (admin/config/media/file-system)
2. Наличие php5-gd (apt-get install php5-gd)
3. Если используется nginx, то наличие правила вида
location ~ ^/sites/.*/files/styles/ {
try_files $uri /index.php?q=$uri;
}
4. Если ничего не помогает admin/reports/dblog в студию.
з.ы. Образец при создании нового правила генерируется нормально ? Т.е. admin/config/media/image-styles/edit/имя_стиля выводит оба изображения ?
creator969
11 февраля 2013 в 13:19
Такая же проблема была, выставил права на папки и все номарльно
Kaylang
4 августа 2013 в 14:45
Есть такая же проблема при попытке программно вывести превью по пресету.
print theme_image_style(
array(
‘style_name’ => ‘стиль превью’,
‘width’ => XXX,
‘height’ => YYY,
‘path’ => ‘public://путь к картинке+картинка’,
)
);
генерится HTML-код
<img typeof=«foaf:Image» src=«путь public/styles/стиль превью/public/путь к картинке+картинка?itok=lbqN3GUt» width=«XXX» height=«YYY» alt=«»/>
но сам файл картинки не создается и при просмотре чисто ссылки сообщение: «Ошибка генерации изображения».
права на папки в норме — запись разрешена.
igorek
2 марта 2014 в 18:00
Решение: В первую очередь проверьте, чтобы урл файла был не от корня сайта, а от папки files.
То есть не ‘sites/default/files/images/image.jpg’, а просто: ‘images/image.jpg‘
Об этом, например, говорится здесь: theme_image_style($variables).
SunriseChild
5 февраля 2015 в 18:15
Во! Спасибун!
Даже специально зарегался чтоб «спасибо!» сказать
Сменил дефолтный путь sites/default/files в «Общедоступный путь файловой системы» на images. Стили сохраняются в норме.
artem1914@yandex.ru
19 апреля 2015 в 16:27
Добрый день, я мало понимаю в Друпале, нашего программиста уволили, а на сайте пропали изображения видео в темах
http://ik-zona.ru/filmy-na-telekanale-zona вот ссылка, пишет ошибка генерации изображения, как можно исправить, и чтоб не сильно заумно, может как нибудь в панеле управления сайтом это можно решить? Если кто подскажет спасибо огромное!
igorek
19 апреля 2015 в 16:43
bobser
11 марта 2016 в 19:42
Была та же проблема. Выставил права доступа 755 на все вложенные папки начиная с /sites/default/files/ и всё заработало.
I am new to Drupal, I am trying to move an existing site from serverA to serverB.
When I visit
http://serverB/sites/default/files/styles/thumbnail/public/publications/43026/cover.jpg
I get Error generating image.
I am using Drupal 7.22, on an ubuntu server, PHP Version 5.4.9, have php5-gd and mod_rewrite installed and activated. Error log of apache server is empty. I also have the following directories created.
mkdir -p /var/www/sites/all/files/styles/thumbnail
mkdir -p /var/www/sites/default/files/styles/thumbnail
chmod 777 /var/www/sites/all/files/styles -R
chmod 777 /var/www/sites/default/files/styles -R
How can I fix/find the source of this problem. Where should I look for some useful error logs.
asked Jul 23, 2013 at 5:10
Ali SalehiAli Salehi
1211 silver badge3 bronze badges
2
Problem is — you are trying to generate styled image, but you do not provide security token. In Drupal 7.20 and later security token is required so images are only generated when Drupal site itself tries to use them. To turn it off, just add the following line to your settings.php file:
$conf['image_allow_insecure_derivatives'] = TRUE;
Solution taken from this answer and 7.20 release notes.
answered Jul 23, 2013 at 6:56
MołotMołot
21.8k8 gold badges57 silver badges110 bronze badges
6
If all permissions are correct. Make sure that ImageMagick is installed on your server for PHP5.
Just run the following commands:
sudo apt-get install imagemagick
sudo apt-get install php5-imagick
Source: https://stackoverflow.com/a/18150533
answered Jan 28, 2014 at 15:36
FWIW :
in my case the problem was that the original image contained errors, so it seems logic that the derivative couldn’t be created
answered Nov 30, 2018 at 10:49
izusizus
1,0758 silver badges18 bronze badges
I am new to Drupal, I am trying to move an existing site from serverA to serverB.
When I visit
http://serverB/sites/default/files/styles/thumbnail/public/publications/43026/cover.jpg
I get Error generating image.
I am using Drupal 7.22, on an ubuntu server, PHP Version 5.4.9, have php5-gd and mod_rewrite installed and activated. Error log of apache server is empty. I also have the following directories created.
mkdir -p /var/www/sites/all/files/styles/thumbnail
mkdir -p /var/www/sites/default/files/styles/thumbnail
chmod 777 /var/www/sites/all/files/styles -R
chmod 777 /var/www/sites/default/files/styles -R
How can I fix/find the source of this problem. Where should I look for some useful error logs.
asked Jul 23, 2013 at 5:10
Ali SalehiAli Salehi
1211 silver badge3 bronze badges
2
Problem is — you are trying to generate styled image, but you do not provide security token. In Drupal 7.20 and later security token is required so images are only generated when Drupal site itself tries to use them. To turn it off, just add the following line to your settings.php file:
$conf['image_allow_insecure_derivatives'] = TRUE;
Solution taken from this answer and 7.20 release notes.
answered Jul 23, 2013 at 6:56
MołotMołot
21.8k8 gold badges57 silver badges110 bronze badges
6
If all permissions are correct. Make sure that ImageMagick is installed on your server for PHP5.
Just run the following commands:
sudo apt-get install imagemagick
sudo apt-get install php5-imagick
Source: https://stackoverflow.com/a/18150533
answered Jan 28, 2014 at 15:36
FWIW :
in my case the problem was that the original image contained errors, so it seems logic that the derivative couldn’t be created
answered Nov 30, 2018 at 10:49
izusizus
1,0758 silver badges18 bronze badges
I don’t know why Drupal stopped generating thumbnails. So, I get error on files like this:
/sites/default/files/styles/choices/public/a1531172504.jpg?itok=Wn-VWDKd
Although the full image is found in:
/sites/default/files/a1531172504.jpg
I’m working on Nginx, Drupal 7
asked Jul 9, 2018 at 22:12
1
Last time I’ve answers question related to image derivatives I’ve got minuses so let be thorough here.
1.Drupal core will NOT create image derivative upon image upload — fact.
2.Thumbnail image (derivative from original image) is physically created upon HTTP request eg. if you visit the listing where image is used (when you visit the listing with thumbnail image the derivative is created on the fly via HTTP request)
3.To alter this behavior and to get a derivative image instantly upon image upload via CCK field you must use module Imageinfo Cache https://www.drupal.org/project/imageinfo_cache
With this info form above please recheck your site (go to listing where the thumbnail should appear and than check your thumbnail folder) If the image is still missing please provide more details like: Are you using CCK field or is it a custom field, are you creating derivative programmatically? Some code snippets are required here to solve you problem.
Also please check your .htaccess located in sites/default/files/.htaccess (not the general .htaccess)
and while you there check the permissions on files folder.
answered Jul 10, 2018 at 14:44
BeyerBeyer
1718 bronze badges
2
The solution for me was to add this lines to the nginx.conf
files:
location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
# not working with Drupal rewrite module: rewrite ^/?(.*?)/?$ /index.php?q=$1&$args;
rewrite ^/?(.*?)/?$ /index.php/$1&$args;
}
My environment is:
- docker-compose with nginx (nginx:1.17.4-alpine), drupal
(drupal:9.0.6-fpm-alpine) and mysql (mysql:8.0)
- drupal (9.0.6), nginx/1.17.4, PHP 7.4.10, MySql 8.0.21
The server responded with a 404 error
because:
- The image styles are generated when drupal receives a request.
- Nginx receives a request for an image that is not in the filesystem; then returns a 404 instead redirect the request to drupal.
The rule I propose for the nginx.conf
redirect the image request to drupal
and solve the problem after restart the web server:
docker-compose restart webserver
iminiki
2,41112 gold badges34 silver badges44 bronze badges
answered Sep 27, 2020 at 16:32
My fix was to disable and re-enable the clean-url. .../admin/config/search/clean-urls"
.
double-beep
4,86916 gold badges32 silver badges41 bronze badges
answered May 10, 2019 at 12:14
В случае отказа от apache и использования nginx в связке с php5-fpm может появиться проблема. Все работает, а изображения не создаются.
Проблемы могут быть в трех случаях.
1) Не верные права на директорию.
Решение
find . -type d -print0 | xargs -0 chmod 755
find . -type f -print0 | xargs -0 chmod 644
по умолчанию права на папку с миниатюрами и другими стилями должны быть 755, так же проверьте права, на запись сервером. Владелец должен быть или специальный пользователь или сервер.
Сменить права можно с помощью команды chown, например сменим права на всю директорию где находится сайт
chown -R www-data:www-data my_site_dir
где my_site_dir нужная нам папка
2) Отсутствие расширения php для работы с изображениями. Проверить можно с помощью тестового файла вида.
<?php
var_dump(gd_info());
?>
называем его например, test-gd.php, закидываем в корень сайта и открываем.
При правильной настройке увидим что-то подобное
array(12) {
["GD Version"]=>
string(27) "bundled (2.0.34 compatible)"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["T1Lib Support"]=>
bool(true)
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
В первых строках указана версия библиотеки, если она установлена.
3) Самая сложно вычисляемая причина — неправильный конфиг nginx
ImageCache в Drupal 7 принимает информацию об отсутсвующих файлах через 404 ошибку с сервера, и если файла нет, то создает новое изображение с заданными параметрами.
Тот конфиг что гуляет по русскоязычной версии сети не учитывает этот момент. Необходимо дописать следующие правила
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}
после обновить страницу с миниатюрами, они должны появиться.
almost a fresh installed Drupal 7
new «article», select a image to upload, after uploading finished, the image is upload successfully to «…/sites/default/files/field/image/pen_1000_750_0.jpg».
And a thumbnail, pointed to «…/sites/default/files/styles/thumbnail/public/field/image/pen_1000_750_0.jpg», is supposed to be shown before the above link, however, it’s broken. I even can’t find the fold of «…/sites/default/files/styles/public/filed» on server host.
Comments
Version: | 7.0 | » 7.2 |
Assigned: | Unassigned | » straszko |
Priority: | Normal | » Major |
Status: | Closed (fixed) | » Active |
Issue tags: | +clean URL |
Hello,
installed Drupal 7.2 and have problems with uploaded images (through image_field)…
When Clean URLs disabled everything seems to work fine (all images visible).
When Clean Urls enabled image presets (ex.: thumbs, medium, large) are not showing… but original size image visible..
any help appreciated…
regards.
- Log in or register to post comments
Comment #3
sun
German
Karlsruhe
CreditAttribution: sun commented 8 June 2011 at 02:40
Version: | 7.2 | » 7.0 |
Priority: | Major | » Normal |
Status: | Active | » Closed (fixed) |
Issue tags: | -clean URL | +nginx |
@straszko: Please search the queue for existing issues. If you don’t find an issue that directly maps to your problem, create a new one. However, don’t abuse the priority level, please.
- Log in or register to post comments
Sorry, is there a fix for 7.2?
I’m facing the same issue, the thumbnail preview is not showing.
Actualy looking at the html code of the form:
<div class="image-preview"><img alt="" src="http://soglu-li50.heb.fr.colt.net/sites/default/files/styles/thumbnail/public/images/articles/articles_contenu/banniere/tmp-sponsoring.jpg" typeof="foaf:Image"></div>
And looking into my server, i actualy have the folder created but it’s empty. What could prevent the thumbnail from being generated?
EDIT: Actualy, it seems that Drupal is just not generating thumbnail for jpg, only png.
Still weird that it creates folders and html even then though!
- Log in or register to post comments
Version: | 7.0 | » 7.2 |
Assigned: | straszko | » Unassigned |
Priority: | Normal | » Major |
Status: | Closed (fixed) | » Active |
Issue tags: | -nginx |
Well for some reason i don’t have any thumbnail generated for .jpg file.
As i stated above the HTML code is generated to display thumbnails but there is no such image in the folder.
- Log in or register to post comments
Comment #6
StevenPatz
English
Alexandria VA
CreditAttribution: StevenPatz commented 29 June 2011 at 14:03
Status: | Active | » Closed (fixed) |
- Log in or register to post comments
I’m experiencing the same problem, ever find a solution?
- Log in or register to post comments
Check your logs.
For me it was because of some missing Php libraries.
And i also had another issue because of rights settings on my server.
- Log in or register to post comments
Comment #9
onny CreditAttribution: onny commented 6 November 2011 at 01:46
I’m experience this kind of bug while using media_gallery module. The Images are uploaded but Drupal does not generate the thumbnails. Strangely, after turning «Clean URL» off and on again, the thumbnails appear :/ Any way to debug this? Couldn’t find anything useful in Firefox WebConsole nor Apache/PHP-Logs …
- Log in or register to post comments
What host are you using? I’m using hostgator — same problem
- Log in or register to post comments
Same problem, original image is uploaded but the thumbnails are not created. The folders are there but not the thumbnail files. Nothing is shown in error logs which is frustrating.
Using the media module for upload (nginx server).
GD has everything installed:
Array ( [GD Version] => bundled (2.0.34 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => 1 [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => 1 [XBM Support] => 1 [JIS-mapped Japanese Font Support] => )
EDIT:
It was a nginx config that caused the problem… stupid mistake /facepalm. This bypassed php all together = no thumbnails.
Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
root /home/www/web;
}
- Log in or register to post comments