@@ -18,7 +18,8 @@ export default function () {
1818 if ( ! toggleImagesBtn ) return
1919
2020 // If there are no images on the page, return!
21- const images = document . querySelectorAll ( 'img' )
21+ // Don't include images in tables, which are already small and shouldn't be hidden.
22+ const images = [ ...document . querySelectorAll ( 'img' ) ] . filter ( img => ! img . closest ( 'table' ) )
2223 if ( ! images . length ) return
2324
2425 // The button is hidden by default so it doesn't appear on browsers with JS disabled.
@@ -41,9 +42,6 @@ export default function () {
4142
4243 // For every image...
4344 for ( const img of images ) {
44- // Ignore images in tables, which are smaller than other images.
45- if ( img . closest ( 'table' ) ) continue
46-
4745 const parentSpan = img . parentNode
4846 // Create a button and add some attributes.
4947 const parentButton = document . createElement ( 'button' )
@@ -54,7 +52,6 @@ export default function () {
5452 // This mostly applies to images in ordered lists nested in spans (via lib/render-content/create-processor.js).
5553 // It will have no effect with images that are not in ordered lists.
5654 parentSpan . parentNode . replaceChild ( parentButton , parentSpan )
57- // parentSpan.appendChild()
5855
5956 // Set the relevant tooltip text, and hide the image if that is the preference.
6057 if ( hideImagesPreferred ) {
0 commit comments