Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to restrict the size of the custom background image? I recently released a theme and I notice that people are uploading very large images to use as background image which of course causes the page to load very slow.

Can you specify the dimensions of the background image somehow so that after the upload the image will be resized?

share|improve this question

1 Answer 1

There are two parts to the answer:

  1. You can set the size of images using add_image_size. This is done in your functions.php.

    add_image_size( 'background-image', 900, 500 ); //900 px wide 500px high - no crop
    
  2. Once this is set you will need to regenerate your thumbnails. There are number of great plug-ins that can help you with that task. After you add the new image size all future imports will be sized correctly. Now to use it you can call the Wordpress thumbnail:

    the_post_thumbnail('background-image');

Depending on how you saved the image, you may need to use another method to recall the image size but there are a number of ways to do this.

share|improve this answer
    
The images get uploaded by the WordPress theme functionality "custom-background" this won't work. –  user2019515 Oct 7 '13 at 11:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.