0

I have learned that when upload a single image, WP will automatically create 3 copies of it as Thumbnail (150×150), Medium (300×300), Large (1024×1024) & original size.

  1. does that mean if I use css to set image width, WP will automatically get the corresponding size image (that WP created) to use?
  2. if I dont set any width for image (max-width: 100%), what happen when the screen is scaling smaller, does WP still automatically get corresponding size image to use?
  3. is the right way means I should upload an image with the exact native size that I need to use on desktop screen and not worry anything about responsive image?
0

It's change automatically change image while image's in responsive mode.We can add all images here so it's cut automatically with screen size.

add_action( 'after_setup_theme', 'wpdocs_theme_setup' );
function wpdocs_theme_setup() {
 add_image_size( 'category-thumb', 300 ); // 300 pixels wide (and unlimited height)
 add_image_size( 'homepage-thumb', 220, 180, true ); // (cropped)
}
0

Yes, WordPress generates copies of several sizes when you upload an image. You can even set which sizes are generated, either through the dashboard or with a plugin (example) or in your theme.

This does not mean that all these sizes are automatically included anytime you insert an image. For instance, when you insert an image in a post, you're supposed to pick the size. However, if the featured image is inserted in the right way by your theme, all image sizes are included.

This happens by using the srcset attribute on the image. Basically, what this does is tell te browser which sizes are available. The browser will calculate the size the image has on the screen and then load the appropriate file from your server, also when the window is resized. That should answer the first and second part of your question.

Now, for the third part. Always upload the largest size available of any image. Have WP scale it down to the exact size for your desktop. In this way, if you change your theme later on and need a larger image, you still have that available in your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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