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

Python 3 - Fun with Python String

Python 3 - Fun with Python String

This post some useful tips of using strings, and some issues while dealing with…

Mongoose - Using CRUD operations in mongodb in nodejs

Mongoose - Using CRUD operations in mongodb in nodejs

MongoDB CRUD Operations Mongoose provides a simple schema based solution to…

How to Deploy Strapi with Next.js Frontend with Nginx Proxy and URL Redirect with Docker

How to Deploy Strapi with Next.js Frontend with Nginx Proxy and URL Redirect with Docker

Agenda I will cover following in this post: Prepare Docker image for Next.js app…

Python - How to Implement Timed-Function which gets Timeout After Specified Max Timeout Value

Python - How to Implement Timed-Function which gets Timeout After Specified Max Timeout Value

Introduction We often require to execute in timed manner, i.e. to specify a max…

Kubernetes - How to Configure Docker Repository to Pull Image and Configure Secret

Kubernetes - How to Configure Docker Repository to Pull Image and Configure Secret

Introduction In most of cases, you are not pulling images from docker hub public…

Azure Storage Blob - How to List Blob, Download Blob from Azure Storage container in Python (pypy libs)

Azure Storage Blob - How to List Blob, Download Blob from Azure Storage container in Python (pypy libs)

Introduction In this tutorial we will see: How to instantiate different classes…

Latest Posts

System Design Patterns for Scaling Writes

System Design Patterns for Scaling Writes

In the companion article on scaling reads, we covered caching, replicas, and…

Serverless vs Containers — The Decision I Keep Revisiting

Serverless vs Containers — The Decision I Keep Revisiting

Every time I start a new service, I have the same argument with myself. Lambda…

System Design Patterns for Scaling Reads

System Design Patterns for Scaling Reads

Most production systems are read-heavy. A typical web application sees 90-9…

Building a Production RAG Pipeline — From Chunking to Retrieval to Generation

Building a Production RAG Pipeline — From Chunking to Retrieval to Generation

Large Language Models are powerful, but they hallucinate. They confidently make…

Prompt Engineering Patterns That Actually Work in Production

Prompt Engineering Patterns That Actually Work in Production

Most prompt engineering advice on the internet is useless in production. “Be…

Jenkins Pipeline with Jenkinsfile - How To Schedule Job on Cron and Not on Code Commit

Jenkins Pipeline with Jenkinsfile - How To Schedule Job on Cron and Not on Code Commit

Introduction In this post we will see following: How to schedule a job on cron…