I’ve tracked down the issue, it’s coming from:
/wp-content/plugins/patreon-connect/classes/patreon_protect.php:
$attachment_id = attachment_url_to_postid( $attachment_url );
// attachment_url_to_postid returns 0 if it cant find the attachment post id
if ( $attachment_id == 0 ) {
// Couldnt determine attachment post id. Try to get id from thumbnail
$attachment_id = Patreon_Protect::getAttachmentIDfromThumbnailURL( $attachment_url );
if( $attachment_id == 0 ) {
$message = 'Can not find attachment id. Cannot lock.';
}
}
attachment_url_to_postid should not ever fail since it’s from WordPress, but your own function fails as well Patreon_Protect::getAttachmentIDfromThumbnailURL( $attachment_url ).
I`m still tracking down why this is happening.
UPDATE:
I found the cause, attachment_url_to_postid fails when the url passed is NOT the exact filename.
For example, in my case it’s sending:
pw_image_source:
https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-1024x512.png
When testing the function it was always returning 0:
echo 'TEST: ' . attachment_url_to_postid( 'https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-1024x512.png' );
die();
However when I removed the “size” from the filename:
echo 'TEST: ' . attachment_url_to_postid( 'https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat.png' );
die();
I has correctly returned to me the attachement id. Now all that’s left is to figure out what to do I guess
UPDATE 2:
Using the above “temporary” solution, if you set the image size to Full Size in Gutenberg the lock image does not return anymore errors.
However… the image is not actually “locked”. Checkout the generated HTML:
<img data-lazyloaded="1" src="https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-1024x512.png.webp"
data-src="https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-1024x512.png.webp"
alt=""
data-patreon-flow-url="aHR0cHM6Ly9tZWNhbmlrLmRldi9wYXRyZW9uLWZsb3cvP3BhdHJlb24tdW5sb2NrLXBvc3Q9MTg3JnBhdHJlb24tdW5sb2NrLWltYWdlPTE5Mg=="
class="patreon-locked-image wp-image-192 litespeed-loaded"
data-srcset="https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-1024x512.png.webp 1024w, https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-300x150.png.webp 300w, https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-768x384.png.webp 768w, https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat.png.webp 1200w"
data-sizes="(max-width: 1024px) 100vw, 1024px"
sizes="(max-width: 1024px) 100vw, 1024px"
srcset="https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-1024x512.png.webp 1024w, https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-300x150.png.webp 300w, https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat-768x384.png.webp 768w, https://MY_BLOG/wp-content/uploads/2020/05/Thinking-of-getting-a-cat.png.webp 1200w"
data-was-processed="true">
Notice that the Patreon stuff is there though. The image is visible and we can see again the annoying “size” in the filename.
At this point I don’t know whether it’s the function I mentioned from WP, or the fact that I`m using LSCACHE and it serves .webp.
Please advice, I leave it in your hands from here.