WordPress retrieve media except cropped


I’m retrieving all the images in the Media using the following code:

$query_images_args = array(
    'post_type'      => 'attachment',
    'post_mime_type' => 'image',
    'post_status'    => 'inherit',
    'posts_per_page' => - 1,
    'order'         => 'ASC'

$query_images = new WP_Query( $query_images_args );

// Get all the available thumbnail sizes
$sizes = get_intermediate_image_sizes();

$images = array();
$thumbnails = array();
foreach ( $query_images->posts as $image ) {

    $image_meta = wp_get_attachment_metadata($image->ID);
    $image_size_url = wp_get_attachment_image_src($image->ID, 'thumbnail');
    $images[] = $image_size_url;

It retrieves the images but it’s also retrieving the cropped files which WordPress creates when I DND the original images into the Media section. Is there a way to prevent querying these images aside from checking for the word "cropped-" at the beginning of the filename? Or would I use apply_filters() to filter those images out?

adviner 2 months 0 Answers 8 views 0

Leave an answer