[wp-trac] [WordPress Trac] #59331: Image optimizations fail to apply when using Timber

WordPress Trac noreply at wordpress.org
Tue Sep 12 18:48:38 UTC 2023


#59331: Image optimizations fail to apply when using Timber
--------------------------+-----------------------------
 Reporter:  westonruter   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Future Release
Component:  Media         |     Version:  6.3
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+-----------------------------

Comment (by westonruter):

 Here's a workaround plugin that addresses the issue with `the_content`
 images in a Timber-based theme:
 https://gist.github.com/westonruter/456afa3cbf29563ffd590401988f1a23

 It uses HTML Tag Processor to optimize images in the first `the_content`:

 * The first five images have the `loading` attribute removed.
 * Each initial image's dimensions are captured and the largest one is
 given `fetchpriority=high`.
 * As soon as a second paragraph is encountered, optimization is halted.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59331#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list