Get posts with specific custom field filled and specific custom image size generated in WordPress

I would like to get posts, only with specific custom field type ‘image’ filled, and only what have specific image custom size generated, is that possible?

In post form, ‘cover’ is my custom field type ‘image’ and I have a custom image size called ‘highlights’ in funtions.php.

Read More
add_image_size('highlights',1280,640,true);

Thats my code:

$args = array(
    'post_type'      => 'post',
    'posts_per_page' => 3,
    'offset'         => 0,
    'meta_query'     => array(
        array(
            'key'     => 'cover',
            'value'   => '',
            'compare' => '!='
        ),
    ),
);

$posts = get_posts($args);

I get the posts whats have the field ‘cover’ filled, but, I would like to filter only what have ‘hightlights’ size generated.

Any help will be much appreciated.

Related posts