Skip to content

Commit 783924e

Browse files
authored
Image sizing problem in feed (#115)
* Create docker configuration for local development * Fix WP 6.7 chrome problem with lazy loading
1 parent c06ee66 commit 783924e

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ Wordpress theme of the STC blog [studuj.digital](https://studuj.digital/).
88
## About project
99
Based on [STCblog template](https://github.com/andreondra/stcblog).
1010

11+
## Local development
12+
13+
```sh
14+
docker-compose -p stcblog up --build # Build and run dev version in docker image
15+
```
16+
1117
## Features
1218
### Responsive
1319
![responsivity showcase](docs/img/readme1.gif)

docker-compose.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3.8'
2+
services:
3+
wordpress:
4+
image: wordpress:6.7.1
5+
container_name: wordpress-dev
6+
ports:
7+
- "8080:80"
8+
environment:
9+
WORDPRESS_DB_HOST: db
10+
WORDPRESS_DB_USER: exampleuser
11+
WORDPRESS_DB_PASSWORD: examplepass
12+
WORDPRESS_DB_NAME: exampledb
13+
volumes:
14+
- ./:/var/www/html/wp-content/themes/current-theme
15+
16+
db:
17+
image: mysql:8.0
18+
container_name: wordpress-db
19+
environment:
20+
MYSQL_DATABASE: exampledb
21+
MYSQL_USER: exampleuser
22+
MYSQL_PASSWORD: examplepass
23+
MYSQL_RANDOM_ROOT_PASSWORD: '1'
24+
volumes:
25+
- db:/var/lib/mysql
26+
27+
volumes:
28+
db:

functions.php

+20
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,24 @@ function disable_emojis() {
393393
}
394394
add_action('init', 'disable_emojis');
395395

396+
397+
/**
398+
* Disable Chromium feature that applies `contain-intrinsic-size` to images with
399+
* `sizes="auto"` attribute. This prevents unexpected layout shifts caused by
400+
* missing `width` and `height` attributes.
401+
*
402+
* WordPress 6.7 introduced a feature that automatically adds `loading="lazy"`
403+
* to images without validating the presence of these attributes. This behavior
404+
* can cause rendering issues, especially in Chromium-based browsers, due to
405+
* their CSS adjustments for such images.
406+
*
407+
* Applying this filter disables the `auto-sizes` feature in WordPress until
408+
* a permanent patch is released (scheduled for version 6.7.1).
409+
*
410+
* @link https://core.trac.wordpress.org/ticket/62413
411+
* @link https://ericportis.com/posts/2023/auto-sizes-pretty-much-requires-width-and-height/
412+
* @author Petr Kucera
413+
*/
414+
add_filter('wp_img_tag_add_auto_sizes', '__return_false');
415+
396416
?>

0 commit comments

Comments
 (0)