Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22
【WordPress】テーブルの幅・高さが勝手に変わる問題の解決方法
Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

【WordPress】画像にAltタグを自動で入れる方法

WordPress
Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

WordPressで画像にAltタグを自動で入れる方法を紹介。画像のファイル名をそのままAltタグに設定できるようになるので、functions.phpへの記述内容をまとめています。

画像にAltタグを自動で入れる方法

デフォルト 自動化後
デフォルトのメディア 自動化後のメディア
<img src=”〇〇.jpg” alt=”” width=”〇〇” height=”〇〇” /> <img src=”〇〇.jpg” alt=”本” width=”〇〇” height=”〇〇” />

WordPressで画像を挿入時、画像のAlt(代替テキスト)の設定をすると思います。

アップロードした画像にメディア内で代替テキストを設定後、記事に埋め込むとAltが設定できているというのが基本ですよね。

そこで、テーマのfunctions.phpをカスタマイズして「メディア内で代替テキストを設定する」部分を自動化する方法を紹介します。

ただし、アップロード前のファイル名を基に設定するので、そこまで便利と感じない人もいると思います。

functions.phpへの記述内容

functions.phpへの記述内容

※都合上CSS扱いで載せていますがPHPです

See the Pen ALT自動 by yamay (@yamay) on CodePen.


Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

WordPressの最新記事8件


Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/wp_footer.php on line 17

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/inc/parts/is_mobile.php on line 22

Warning: Undefined array key "HTTP_USER_AGENT" in /home/defwitches/warewareguide.com/public_html/wp-content/themes/the-thor/footer.php on line 425