1

I am trying to migrate a plugin from Craft 3 to Craft4 . The plugin basically checks the entry for a pdf asset and create a thumbnail asset from the PDF using Imagick to save with the entry.

I use to check for the presence of a thumbnail by doing :

$thumbs = $entry->pdfThumbnailImage;

if(count($thumbs) > '0'){
 //more checking code
}

Since php8.1 count above returns:

count(): Argument #1 ($value) must be of type Countable|array, craft\elements\db\AssetQuery given

I am super daft and rusty and wondered how other people are handling the change in count to check for a custom field asset.

1 Answer 1

2
$thumbs = $entry->pdfThumbnailImage->all();

if(count($thumbs) > 0){
 //more checking code
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.