Commit 90912e0ee6f for woocommerce

commit 90912e0ee6f205f6246c8ec3b8cdb84291e2ed2c
Author: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
Date:   Wed Sep 23 09:21:52 2026 +0200

    Restore PDF (and other file types) previews in product galleries (#68957)

    * Restore PDF previews in product galleries

    * Add changelog entry for PDF gallery support

    * Update PDF gallery changelog wording

    * Remove redundant gallery video type check

diff --git a/plugins/woocommerce/changelog/fix-product-gallery-pdf-previews b/plugins/woocommerce/changelog/fix-product-gallery-pdf-previews
new file mode 100644
index 00000000000..506df0c7222
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-product-gallery-pdf-previews
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Restore support for other file types (e.g. PDFs) in product galleries.
diff --git a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
index 634c20a7411..9d4177c6392 100644
--- a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
+++ b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js
@@ -1467,11 +1467,11 @@ jQuery( function ( $ ) {
 	function createProductGalleryMediaItem( attachment, $el, allowVideos ) {
 		const mediaType = attachment.type;

-		if ( 'image' === mediaType ) {
+		if ( 'video' !== mediaType ) {
 			return createProductGalleryImageItem( attachment, $el );
 		}

-		if ( allowVideos && 'video' === mediaType ) {
+		if ( allowVideos ) {
 			return createProductGalleryVideoItem( attachment, $el );
 		}

@@ -1541,9 +1541,6 @@ jQuery( function ( $ ) {
 			states: [
 				new wp.media.controller.Library( {
 					title: $el.data( 'choose' ),
-					library: wp.media.query( {
-						type: allowVideos ? [ 'image', 'video' ] : 'image',
-					} ),
 					filterable: 'all',
 					multiple: true,
 				} ),
diff --git a/plugins/woocommerce/src/Internal/ProductGallery/ProductMediaGallery.php b/plugins/woocommerce/src/Internal/ProductGallery/ProductMediaGallery.php
index 596e394f69b..954e45fa1fa 100644
--- a/plugins/woocommerce/src/Internal/ProductGallery/ProductMediaGallery.php
+++ b/plugins/woocommerce/src/Internal/ProductGallery/ProductMediaGallery.php
@@ -194,7 +194,8 @@ class ProductMediaGallery {
 			if ( 'image' === $media_type ) {
 				if (
 					! wp_attachment_is_image( $attachment_id ) &&
-					0 !== strpos( (string) get_post_mime_type( $attachment_id ), 'image/' )
+					0 !== strpos( (string) get_post_mime_type( $attachment_id ), 'image/' ) &&
+					! wp_get_attachment_image_src( $attachment_id, 'full' )
 				) {
 					continue;
 				}