The following applies to all attchment images on my site:
There is a PNG image attachment, its ID is 519271.
wp_get_attachment_image(519271, 'thumbnail', false, array( 'id' => 'esjb-preview-image' ))
returns "".
wp_get_attachment_image_src(519271)
returns false
.
wp_attachment_is_image(519271)
returns true
The file is there in the uploads folder. Folder permissions are 755. File permissions are 644.
The attachment is in the wp_posts table and the data seems to be OK.
The file has a proper thumbnail in the media library, but when I click on it and it opens the attachment details (/wp-admin/upload.php?item=519271), there's no image there, just the default empty image icon. The details are correct though, including the actual file URL.
I tried deactivating all plugins (except the Really Simple SSL) to no effect.
I re-generated thumbnails using the Regenerate Thumbnails plugin, but the problem still exists.
The site has been hacked recently (WPCoreSys (Dolly) Hack), after which I deleted all files, changed my host password, then uploaded a clean WP, checked my database for any entries that do not belong there, so I presume WP core files are unchanged. The only folders I took from the hacked install were the uploads folder and my theme folder, but I made sure there are no corrupted files there. Anyway, I deactivated my current theme for a time and nothing changed.
Any ideas on what could have caused the problem?
Edit.
This is my code that can't get data:
static function get_image() {
if(isset($_GET['id']) ){
$img_id = (int) $_GET['id'];
$data = array(
'image' => wp_get_attachment_image($img_id, 'thumbnail', false, array( 'id' => 'esjb-preview-image' ))
);
wp_send_json_success( $data );
} else {
wp_send_json_error();
}
}
The PHP class itself, as well as AJAX request, they both work just fine.
Edit 2.
I cloned my site to a sub-domain, created an empty database and imported images from the main site. I.e. the files are just the same. On the cloned site, the code works just fine and retrieves image data. So it looks like the issue in my database, but the wp_posts tables in both databases look identical to me, their structure is the same, the indices are the same, and there's nothing strange in the data...