on-internet
← Community

How to include static images in WordPress Gutenberg templates?

Stack Overflow ·

When using templates in block themes in WordPress, it's sometime useful to use static images. How can we dynamically use a relative path? In this example: <!-- wp:image {"width":"auto","height":"100px","sizeSlug":"full","linkDestination":"none"} --> <figure class="wp-block-image size-full is-resized"> <img src="[STYLESHEET_URI]assets/img/icos/ico-ressources.svg" alt="Static image" style="width:auto;height:100px"/> </figure> <!-- /wp:image --> the purpose is to replace [STYLESHEET_URI] by the stylesheet directory URL. The documentation tells to use PHP: <img src="<?php echo esc_url( get_theme_f

Comments

Sign in or sign up to comment and upvote.

No comments yet.