Setting Image Size in PHP

[ad_1]

Hi Tim!

It would be great if you could share a bit more information so that it’s possible to help you!

  1. What have you tried to set the image size? In the example you shared, you are only adding a src attribute. You might want to add a width or height. For example, if you want the image to have a fixed height of 300px you could do this: echo '<img src="' . esc_url( plugins_url( '/plugin-name/assets/img/image.png' ) ) . '" width="300"> ';
  2. Is there an error message? If yes, what does it say?
  3. What is the plugin-name in your example?
  4. In general, it is better to leave the image handling to WordPress itself. Is there any reason you could not use the Image block on your site?

Hi Michal,

Thank you very much for your quick response, and thank you for your suggestion, as that corrected the issue. I was using single quotes which was producing an error.

Cheers!

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer