Hello. I have a hat that has a background image. It is displayed as a background. <header class="header_image" style="background-image: url(<?php header_image(); ?>);"> . The function header_image () displays the original image. How can I make a large image of 1024x613 be displayed? You can suggest to change the function. enter image description here Picture

  • @KAGGDesign wp-kama.ru/function/get_header_image If you need to display the URL on the screen and not get it for processing, use the function header_image (). Everything works for me in this way. - Maxim Shmidt
  • And why not just upload a picture of the right size? - SeVlad
  • @SeVlad, because another user can not do this, and the site will take longer to load due to this. - Maxim Shmidt
  • Some "other" user (not admin) can change the picture in the header? 0_O Oh, the horror ........ A "load longer" will NOT be due to the physical size of the picture, but because of the size of the file. Who does not know how to optimize graphics - those generally should not be allowed to site building. - SeVlad 2:51 pm
  • @SeVlad, this is a template for sale. Themeforest and others. - Maxim Shmidt

1 answer 1

Unfortunately, this function does not work with image id, so standard means of displaying smaller images will not help. You can do this:

 $url = get_header_image(); $url = str_replace( '.jpg', '-1024x613.jpg', $url ); echo esc_url( $url); 
  • Thank! Only not get_header_img, but get_header_image. - Maxim Shmidt
  • For sure. Fixed a typo. - KAGG Design
  • Count it, it turns out for a "template" for sale in paid dumps :) - SeVlad
  • @SeVlad to my crutch code from the answer there is the place)) - KAGG Design
  • @SeVlad but seriously, I don't understand why header_image is so ugly done, not through id - KAGG Design