How to Properly Add Images in WordPress (Step by Step)

Adding images to your WordPress website is crucial for enhancing visual appeal, improving user experience, and boosting SEO. However, images can also slow down your site and create a poor user experience if not optimized properly.

In this comprehensive guide, we will walk you through the steps to correctly add images in WordPress to avoid common mistakes.

Why Proper Image Optimization Matters

Here are some of the benefits of optimizing your images correctly in WordPress:

  • Faster load times – Properly compressed image formats load much faster. This improves site speed and user experience.

  • Better SEO – Optimize images with descriptive alt text and titles. This helps search engines understand the content.

  • Enhanced accessibility – Add proper alt text so screen readers can convey context to visually impaired users.

  • Responsive design – Insert responsive images that adapt to different devices. This improves UX.

  • Save storage space – Compressed images take up less storage space on your server.

  • Smoother user experience – Fast loading, properly inserted images keep users happy.

In short, optimizing images improves site speed, SEO, accessibility, UX, and saves storage space.

Step 1 – Use the Right Image Format

The first step is choosing the right file format for your images in WordPress.

Here are the most common image formats and their pros and cons:

  • JPEG – Great for photos. Compressed format means smaller file size. Lossy compression leads to quality loss.

  • PNG – Good for logos and illustrations. Lossless compression retains quality. Larger file size than JPEG.

  • GIF – Small animated images. Supports transparency. Large file size for photos.

  • SVG – Vector format for logos and icons. Infinitely scalable. Animation support.

  • WEBP – Newer compressed format by Google. Great compression but limited browser support.

For most photos, JPEGs are the best choice. Make sure to use quality 60-80% for small file sizes. PNGs are better for logos, illustrations, and transparent images.

Optimize PNGs further by compressing them without losing quality. For simple animations, GIFs may be suitable. Consider WebPs for supported browsers if you want maximum compression.

Step 2 – Resize and Compress Images

The next vital step is resizing and compressing images before uploading them to WordPress. This significantly reduces file size without losing perceptible quality.

Here are some tips:

  • Resize overly large images to fit your page layout. For most websites, 1000-1200 pixels width is sufficient.

  • Use a compression tool like TinyPNG to optimize images. It can compress PNGs and JPEGs by up to 80% without quality loss.

  • Set a reasonable maximum upload size like 2MB in your media settings. Larger images are unlikely to be necessary.

  • For PNGs, remove unnecessary metadata with a tool like PNGOptimizer.

  • Consider using a plugin like EWWW Image Optimizer to automatically compress images on upload.

Compressing images this way keeps file sizes low without sacrificing visual quality. Just don‘t overdo the compression and end up with pixelated, blurry images.

Step 3 – Insert Images in WordPress

With properly formatted and optimized images, it‘s time to learn how to insert them into WordPress posts and pages.

There are a couple of ways to add images in WordPress:

Using the Block Editor

The block editor is the default editor in new WordPress installations. Here‘s how to add images with it:

  1. In the block inserter, search for ‘Image‘ and click the Image block icon.

  2. Click the Upload button to choose an image from your media library or upload a new one.

  3. Once inserted, add appropriate alt text, title, caption, etc. in the sidebar.

  4. Customize dimensions, alignment, borders, etc. as needed.

  5. Click Update or Publish when complete.

The block editor provides fine-grained control over image properties. Take advantage of options like adding spacing, borders, shadows, etc. to craft professional looking images.

Using the Classic Editor

For the legacy classic editor, here are the steps to add images:

  1. Place cursor where you want the image on your page or post.

  2. Click the Add Media button to launch the media library.

  3. Select an existing image or upload a new one from your computer.

  4. In the attachment details popup, add alt text, title, caption, etc.

  5. Click Insert into post to add the image to your content.

  6. Adjust alignment or dimensions by clicking the image placeholder.

  7. Click Update or Publish to save your changes.

While not as feature-rich as the block editor, the classic editor still allows you to add images easily and customize them.

Through the Media Library

You can also add images to your media library first before inserting them into posts:

  1. Go to Media > Add New in your dashboard.

  2. Upload the image you want or select existing ones to edit.

  3. Give it an intuitive title, alt text, caption, etc. in the right sidebar or edit media popup.

  4. Crop or edit the image if needed before clicking Update.

  5. Insert the image into your post using an Image block as outlined earlier.

Adding important images to your media library first lets you reuse them easily across multiple posts.

Step 4 – Optimize Images for SEO

Optimizing your images for SEO gives you a boost in Google image search results. Here‘s how to do it properly:

Descriptive File Names

Use descriptive file names like my-family-vacation-paris.jpg instead of random strings like img987.jpg. This helps search engines understand the image content.

Image Titles

An image title attribute displays when hovering over the image. Craft descriptive titles using keywords related to the image.

Alt Text

Write detailed alt text summarizing the image content. Keep it under 125 characters. This helps with SEO and accessibility.

Caption

Add useful captions below each image. Aim for one or two sentences summarizing the image visually.

Image Description

Expand on the caption by writing a more detailed description of the image content.

Focus on Keywords

Use relevant keyword phrases related to the image topic when writing titles, alt text, captions, etc. Don‘t over-optimize though.

An SEO plugin like Yoast SEO can help generate rich previews with images. There are also plugins to auto-generate alt text.

Step 5 – Make Images Responsive

With more users accessing the web on mobile devices, making your images responsive is a must.

Here are some tips to make images adapt seamlessly across screen sizes:

  • When inserting images in WordPress, enable the Responsive option in the block sidebar.

  • Use the correct HTML for embedding responsive images in your theme code.

  • Set image max-width to 100% so they don‘t overflow their containers.

  • Avoid setting a static height and width on images. Let them scale automatically.

  • If needed, create multiple image sizes for different breakpoints.

  • Consider serving Next-Gen formats like WebP to mobile users.

  • Enable lazy loading to load images only when scrolled into view.

With responsive techniques, your images will look great whether visitors use a smartphone, laptop, tablet, or desktop.

Step 6 – Allow Users to Upload Images

If your site relies on user-generated content, allowing image uploads is a must. Here‘s how to do it securely:

  • Use a secure file upload plugin like WPForms to handle submissions.

  • Limit uploads to images only by filtering file types. Common image extensions are JPG, PNG, GIF, WEBP.

  • Set sane limits for max upload size, dimensions, and number of images.

  • Prevent malicious files by scanning uploads for viruses and exploits.

  • Hold submissions for moderation before public display to filter out inappropriate images.

  • Store original high-res uploads but serve compressed sizes to website visitors.

  • Require user registration and admin approval for image uploads if needed.

With some thoughtful precautions, you can safely allow users to expand your image library with their own contributions.

Conclusion

Adding images to WordPress properly is vital for site performance, design, SEO, and user experience. By following the best practices outlined in this guide, you can insert optimized, fast loading images that look great across devices.

Some key takeaways:

  • Choose the optimal file format – JPEG for photos, PNG for logos and illustrations.

  • Compress and resize images before uploading for faster page loads.

  • Write effective alt text, titles, and captions to make images SEO-friendly.

  • Make images responsive so they adapt smoothly across screen sizes.

  • Allow users to upload images securely if user-generated content is important for your site.

The effort you put into properly adding and optimizing images in WordPress will pay dividends in terms of site speed, design, conversions, and user happiness.

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.