Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
makbeta opened this issue Feb 6, 2020 · 2 comments
Open

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

makbeta opened this issue Feb 6, 2020 · 2 comments

Comments

@makbeta
Copy link

makbeta commented Feb 6, 2020

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 );
		}
@bkjproductions
Copy link

The code indicated by @makbeta above seems to work for Regenerate Thumbnails version 3.1.5 as of 2022-06-01 (using WordPress version 6.0).

However, to regenerate a thumbnail for a PDF in the Media Library, you can only do that if you use the Bulk Actions in the Media Library and have selected a PDF using the checkbox. (That is, the option to regenerate a PDF thumbnail does NOT appear when editing the Media, nor does it appear below the title of the Media in the Media Library list view.)

docs pdfs do not allow thumbnail regneration
docs you must click a checkbox and choose Bulk Actions in order to regenerate PDF

Also, IMHO the thumbnail generated is very bitmappy, and yes, ImageMagick library is in PHP.

@gikaragia gikaragia removed the [Status] Queued In the queue of issues to work on next. label Dec 5, 2022
@Cedders68
Copy link

However, to regenerate a thumbnail for a PDF in the Media Library, you can only do that if you use the Bulk Actions in the Media Library and have selected a PDF using the checkbox. (That is, the option to regenerate a PDF thumbnail does NOT appear when editing the Media, nor does it appear below the title of the Media in the Media Library list view.)

This is true. However, if you do a bulk operation of attachments of various types, the error message is confusing ant unnecessary.
Skipped Attachment ID nnnn (filename): The fullsize image file cannot be found in your uploads directory at . Without it, new thumbnail images can't be generated.

Also, IMHO the thumbnail generated is very bitmappy, and yes, ImageMagick library is in PHP.

I know users who rely on the PDF bitmaps, and they are created in multiple resolutions from full-size, 1024 height and downwards, so I've not been seeing the poor image quality other people have reported.

I've submitted a merge request for commit 27c7083.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants