<pre class="lang-php prettyprint-override"><code>$thumbs = $entry-&gt;pdfThumbnailImage-&gt;all();

if(count($thumbs) &gt; 0){
 //more checking code
}
</code></pre>

CC BY-SA 4.0
2023-08-15T07:14:13.757Z
2023-08-15T07:14:13.757Z
andrew.welch
<p>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.</p>
<p>I use to check for the presence of a thumbnail by doing :</p>
<pre><code>$thumbs = $entry-&gt;pdfThumbnailImage;

if(count($thumbs) &gt; '0'){
 //more checking code
}
</code></pre>
<p>Since php8.1 count above returns:</p>
<pre><code>count(): Argument #1 ($value) must be of type Countable|array, craft\elements\db\AssetQuery given
</code></pre>
<p>I am super daft and rusty and wondered how other people are handling the change in count to check for a custom field asset.</p>

<plugin-development><craft4>
Plugin migration - how to handle count in php8.1
# Plugin migration - how to handle count in php8.1

(Asked by: username_0 on 2023-08-15)

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.

**Tags:** plugin-development, craft4


---

## 1 answers

### Answer by username_1 on 2023-08-15. Score: 2

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

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


---

