Automattic / Automattic/regenerate-thumbnails

PDF images don't regenerate in WordPress v5.3.2 (fix included)

Open
#94 2 comments 1 reaction 0 assignees View on GitHub
[Status] Accepted [Type] Bug
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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.