senrab's avatar

Spatie MediaLibrary (Pro) not converting

I have a model with three media libraries defined

    public function registerMediaCollections(): void {
        $this->addMediaCollection( 'icon' )
             ->singleFile()
             ->withResponsiveImages()
             ->useFallbackUrl( asset( 'solar-energy.png' ) )
             ->registerMediaConversions( function ( Media $media ) {
                 $this
                     ->addMediaConversion( 'preview' )
                     ->width( 300 )
                     ->height( 300 );
             } );

        $this->addMediaCollection( 'documents' )
             ->withResponsiveImages()
             ->registerMediaConversions( function ( Media $media ) {
                 $this
                     ->addMediaConversion( 'preview' )
                     ->width( 300 )
                     ->height( 300 );
             } );

        $this->addMediaCollection( 'confidential_documents' )
             ->withResponsiveImages()
             ->registerMediaConversions( function ( Media $media ) {
                 $this
                     ->addMediaConversion( 'preview' )
                     ->width( 300 )
                     ->height( 300 );
             } );
    }

If I upload an image to any of the media libraries the preview is generated, the icon library seems to work fine - on page reload the preview image is there and confirmed it exists on the filesystem in the conversions sub-directory.

If I upload to the documents media library, the preview is generated again, however on a page reload the image isn't shown and we get a placeholder image. There is no conversions sub directory.

It seems conversions is working for one library but not the others.

All the libraries share the same config

FILESYSTEM_DISK=digitalocean
MEDIA_DISK=digitalocean
QUEUE_CONVERSIONS_BY_DEFAULT=false

All three are saved like this and they are saved, just the conversions aren't triggering for two of the libraries.

        $this->job
            ->syncFromMediaLibraryRequest( $this->files )
            ->toMediaCollection( 'files' );

Running artisan media-library:regenerate doesn't seem to resolve the issue either

Am I missing something?

0 likes
2 replies
alden8's avatar

@senrab

-- ensure you're using the correct collection name (e.g., documents) when accessing converted images

-- even minor typos can prevent conversions from being found

-- if QUEUE_CONVERSIONS_BY_DEFAULT is true, confirm that queue workers are running to process conversions

-- try running php artisan queue:work to process any pending conversions

-- verify that the web server user has write permissions to the conversion directory on the DigitalOcean disk

-- if necessary, adjust permissions using tools like chmod

-- if you've added custom conversion logic, carefully inspect it for errors or inconsistencies

-- temporarily revert to default settings to isolate any configuration-related issues

-- ensure the digitalocean disk is configured correctly in config/filesystems.php

-- check any credentials or API keys required for the disk

senrab's avatar

Thanks for the quick reply @alden8 . I've checked most of those points before posting, confirmed by one of the collections working perfectly and doing exactly what it should.

Please or to participate in this conversation.