Automattic / Automattic/regenerate-thumbnails
PDF images don't regenerate in WordPress v5.3.2 (fix included)
- Dominant language
- PHP
- Stars
- 137
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
The PDF files were skipped and thumbnails weren't generating. Tracked down the issue to a function `get_fullsizepath()` on lines 130-135 in file class-regeneratethumbnails-regenerator.php. The function `wp_get_original_image_path()` will return `false` for PDF file.
The fix is to check for the false positive and fetch PDFs properly.
Code before:
```
if ( function_exists( 'wp_get_original_image_path' ) ) {
$this->fullsizepath = wp_get_original_image_path( $this->attachment->ID );
} else {
$this->fullsizepath = get_attached_file( $this->attachment->ID );
}
```
Code with a fix:
```
if ( function_exists( 'wp_get_original_image_path' ) ) {
$this->fullsizepath = wp_get_original_image_path( $this->attachment->ID );
} else {
$this->fullsizepath = get_attached_file( $this->attachment->ID );
}
// If the function exists and the path is not set, then we likely have a PDF file, try getting the path from attached file funciton
if ( function_exists( 'wp_get_original_image_path' ) && ! $this->fullsizepath ) {
$this->fullsizepath = get_attached_file( $this->attachment->ID );
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Read get_fullsizepath() around lines 130-135 in class-regeneratethumbnails-regenerator.php, then trace how PDF attachments reach that function. Use the issue's included fix as the reference and verify that PDF files are no longer skipped and their thumbnails regenerate successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100