laravel-medialibrary: Spatie\MediaLibrary\Jobs\PerformConversions failed in making conversion
I’m using laradock in my production server and Gd and imagick is installed.
I have checked them both with php -i | grep -i gd
which returns
gd
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
gd.jpeg_ignore_warning => 1 => 1
and php -i | grep -i imagick
returns
/usr/local/etc/php/conf.d/docker-php-ext-imagick.ini,
imagick
imagick module => enabled
imagick module version => 3.4.3
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 6.8.9-9 Q16 x86_64 2017-11-16 http://www.imagemagick.org
Imagick using ImageMagick library version => ImageMagick 6.8.9-9 Q16 x86_64 2017-11-16 http://www.imagemagick.org
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.skip_version_check => 0 => 0
changing in medialibrary.php
'image_driver' => 'gd',
returns the similar type of error
i tried to used nonQueued() function in model but this time mkdir(): Permission denied error occurred
my model looks like this:
use Illuminate\Database\Eloquent\SoftDeletes;
use Spatie\MediaLibrary\Media;
//use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMediaConversions;
class Tour extends Model implements HasMediaConversions
{
use softDeletes,
HasMediaTrait;
protected $dates = ['deleted_at'];
protected $fillable = ['location_id','category_id','operator_id','is_published','title','short_description','slug','base_currency','has_insurrance','is_child_allowed','is_food_allowed','is_featured','has_promotion','request_mode','minimum_seat_booking','average_rating','review_count','created_by','updated_by','deleted_by'];
public function registerMediaConversions( Media $media = null )
{
$this->addMediaConversion('thumb')
->width(150)
->height(120)
->performOnCollections('image')
->nonQueued();
}
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 17 (4 by maintainers)
i had to modify in
vendor/spatie/temporary-directory/src/TemporaryDirectory.php
to change the user from ‘root’ to my docker instance user so that it can create directory inside of the medialibrary directory in laravel storage folder.If the queue operation doesn’t work, then use nonQueued() on conversion Documentation here: https://docs.spatie.be/laravel-medialibrary/v6/converting-images/defining-conversions/#queuing-conversions
If you are in a Linux environment, you can follow the instruction from here:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
or if you are on windows and are using xampp, the process would be similar to this:
https://www.cloudways.com/blog/configure-virtual-host-on-windows-10-for-wordpress/
Thank you for enlighten me. The temporary directory in storage folder has been creating with the root user group which was restricting the package from creating the conversions folder for a specific media. dd’ing the $directoryPath returns
"/var/www/storage/medialibrary/temp/gqhU9vSpveO4CvvV0hlSgHNxMvHX9Zwn"
and i have solved the situation by adding chown function while making directory in path method of this fantastic package:
if anyone is facing the same situation like me, here is what is did:
where 1000 is the uid of the user in my docker instance.
it could be nice addition to the
medialibrary.php
to let user set the user/group name while creating the directory and avoid such circumstances.