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

Missing thumbnails for private attachments in Media library #631

Open
mklasen opened this issue May 1, 2023 · 0 comments
Open

Missing thumbnails for private attachments in Media library #631

mklasen opened this issue May 1, 2023 · 0 comments

Comments

@mklasen
Copy link

mklasen commented May 1, 2023

Heya!

I noticed private attachment thumbnails are not showing when the Media library is shown in (default) grid view. I've solved this on my own environment with the following snippet;

add_filter( 'wp_prepare_attachment_for_js', array( $this, 'prepare_js_attachments' ) );

	public function prepare_js_attachments( $attachment ) {
		$s3_uploads = \S3_Uploads\Plugin::get_instance();
		if ( $s3_uploads->is_private_attachment( $attachment['id'] ) ) {
			if ( isset( $attachment['sizes'] ) && is_array( $attachment['sizes'] ) ) {
				foreach ( $attachment['sizes'] as &$size ) {
					$size['url'] = $s3_uploads->add_s3_signed_params_to_attachment_url( $size['url'], $attachment['id'] );
				}
			}
		}
		return $attachment;
	}

Happy to provide a PR :)

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

No branches or pull requests

1 participant