前提・実現したいこと
wordpressを5.5にアップデートした所、imgタグにに勝手にwidth/height入ってしまい画像が縦伸びしてしまったため、そちらを削除したいと思いfunctions.phpに下記を追記したのですが削除されず画像が伸びたままになってしまいます。
初歩的なご質問で申し訳ございませんがご教授いただけますと幸いです。
参考サイト
https://100webdesign.jp/services/wordpress/wp_result/wp_result-132/
追記
下記を参考にLazy-loadは無効化できたがwidth/heightが残ってしまう。
https://www.nichepcgamer.com/archives/how-to-disable-sitemap-and-lazy-loading.html
該当のソースコード
php
1add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 ); 2add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 ); 3 4function remove_width_attribute( $html ) { 5 $html = preg_replace( '/(width|height)="\d*"\s/', "", $html ); 6 return $html; 7}
試したこと
下記サイトのものも入れて見ましたがダメでした。
https://hirashimatakumi.com/blog/4723.html
https://www.nxworld.net/wordpress/wp-remove-image-attribute.html
記事を見ている感じ5.5から実装されているLazy-loadが原因っぽいです。
https://www.suzukikenichi.com/blog/wordpress-is-planning-to-support-native-lazy-loading/
Lazy-loadを無効化しようと思ったのですが初心者すぎて第4引数がわからず...
https://www.netimpact.co.jp/diary/23076/
補足情報(FW/ツールのバージョンなど)
wordpressのバージョン5.5

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/14 04:15