drupal|April 04, 2020|1 min read

How to regenerate images when you do a style change, and images don't reflect them

TL;DR

Clear the image style cache using drush or delete the styles directory manually to force Drupal to regenerate images with updated style settings.

How to regenerate images when you do a style change, and images don't reflect them

Introduction

There might be a situation when you are doing some changes in the image style, and you want to see those changes on already saved content. But, when do changes, you couldn’t view them. As Drupal makes a cache of those images, but even after clearing cache you did not see expected changes in your images.

Solution

There are two solutions to this problem:

  • Clear image style cache
# make sure you have drush installed

drush image:flush 

# It will list down all your image styles, and ask you to press number which you want to reset

Choose a style to flush [all]:
  [0] Cancel
  [1] all
  [2] 220x180
  [3] 350x250
  [4] 400x310
  [5] 520x280
  [6] large
  [7] medium
  [8] thumbnail

# Type the number and press Enter.

# Or, you can directly type style name, like below:

drush image:flush large
  • Directly delete the folder in sites/default/files folder where this style resides.

Example:

rm -fr sites/default/files/styles/large

Now, refresh your content pages and it will work as expected.

Related Posts

Drupal 8 - How to Theme Form and its Fields with reordering fields

Drupal 8 - How to Theme Form and its Fields with reordering fields

Introduction In this post, we will see how to theme form and its fields…

Drupal 8 - How to create a Page with admin access and create its menu entry in Reports (No Coding)

Drupal 8 - How to create a Page with admin access and create its menu entry in Reports (No Coding)

Introduction I needed a report page, where I wanted to have some information…

Drupal 7 - Code for Exporting all your content nodes in json files

Drupal 7 - Code for Exporting all your content nodes in json files

Introduction When I migrated all of my drupal-7 website to drupal-8, I wrote…

Drupal: How to detect country and redirect to country specific website by using Cloudflare

Drupal: How to detect country and redirect to country specific website by using Cloudflare

Introduction Assume you have a drupal website and using cloudflare. You are…

Twig Templating - Most useful functions and operations syntax

Twig Templating - Most useful functions and operations syntax

Introduction Twig is a powerful template engine for php. Drupal uses it heavily…

Drupal - How to rename column of a content type

Drupal - How to rename column of a content type

Introduction You already have a content type with one or more fields in it…

Latest Posts

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Claude Code Skills — Build a Better Engineering Workflow with AI-Powered Code Reviews, Security Scans, and More

Most developers use Claude Code like a search engine — ask a question, get an…

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Building an AI Voicebot for Visitor Check-In — A Practical Guide to Handling the Messy Parts

Every office lobby has the same problem: a visitor walks in, nobody’s at the…

Server Security Best Practices — Complete Hardening Guide for Production Systems

Server Security Best Practices — Complete Hardening Guide for Production Systems

Every breach post-mortem tells the same story: an unpatched service, a…

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

Staff Engineer Study Plan for MAANG Interviews — The Complete 12-Week Roadmap

If you’re a Senior Engineer (L5) preparing for Staff (L6+) roles at MAANG…

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF Explained — The Complete Guide with Real Attack Examples and Defenses

XSS and CSRF have been in the OWASP Top 10 for over a decade. They’re among the…

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

OWASP Top 10 (2021) — Every Vulnerability Explained with Code

The OWASP Top 10 is the industry standard for web application security risks. If…