How does the media library determine if a PDF file has preview images?

The preview images for PDF documents are created within wp_generate_attachment_metadata() [src].

The full size preview image will have the -pdf.jpg extension [src].

The preview images info for the PDF document is stored in _wp_attachment_metadata in the post meta table.

Here’s an example data for a test.pdf document:

Array
(
    [0] => Array
        (
            [sizes] => Array
                (
                    [thumbnail] => Array
                        (
                            [file] => test-pdf-116x150.jpg
                            [width] => 116
                            [height] => 150
                            [mime-type] => image/jpeg
                        )

                    [full] => Array
                        (
                            [file] => test-pdf.jpg
                            [width] => 1088
                            [height] => 1408
                            [mime-type] => image/jpeg
                        )

                )

        )
)

This is stored as a serialized array under the _wp_attachment_metadata key in the post meta table, but we display it here as an array for better readability.

It’s fetched with wp_get_attachment_metadata() [src], as for any other image attachment.

We can see it e.g. in wp_prepare_attachment_for_js() [src].

Also in image_downsize()[src], that’s used by wp_get_attachment_image_src() [src].

The latter one is used by wp_get_attachment_image(), that’s called within the column_title() method of the media list table, to display the image preview [src].

Hope it helps!