# Some image sizes returning 302 followed by 404

**URL:** <https://forum.ghost.org/t/some-image-sizes-returning-302-followed-by-404/33277>\
**Category:** Developer help\
**Created:** [October 7, 2022, 8:56am UTC](https://forum.ghost.org/t/some-image-sizes-returning-302-followed-by-404/33277 "2022-10-07T08:56:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jslvtr](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jslvtr/32/3273_2.png) [@jslvtr](https://forum.ghost.org/u/jslvtr)\
**Post date:** [October 7, 2022, 8:56am UTC](https://forum.ghost.org/t/some-image-sizes-returning-302-followed-by-404/33277/1 "2022-10-07T08:56:37Z")

</div>

Hi, thanks for the help with this. Running into something a bit weird with images at multiple sizes that have already been created.

- **What’s your URL**?
  - I am limited with how many links I can put as a new user, so the image URLs are linked below, under “Steps to repro the bug/issue”.

- **What version of Ghost are you using?** Latest, 5.17.2

And

- How was Ghost installed and configured? Manually in Ubuntu using `ghost install`.
- What Node version, database, OS & browser are you using?
  - Node 16.17.1
  - MySQL 5.7.33
  - Ubuntu 16.04.03 LTS
  - Browser doesn’t seem to matter, tried in Firefox and Chrome latest.

- What errors or information do you see in the console?
  - Accessing images under `w600` results in multiple redirects, which ends up redirecting to a non-sized version of the image, which returns 404.

## Steps to repro the bug/issue

This image works: [https://blog.teclado.com/content/images/size/w2000/2022/04/christin-hume-mfB1B1s4sMc-unsplash.jpg](https://blog.teclado.com/content/images/size/w2000/2022/04/christin-hume-mfB1B1s4sMc-unsplash.jpg) (the w1000 image works too)  
But in this image you can see the redirects happening (in the dev tools) and the resultant 404: [https://blog.teclado.com/content/images/size/w600/2022/04/christin-hume-mfB1B1s4sMc-unsplash.jpg](https://blog.teclado.com/content/images/size/w600/2022/04/christin-hume-mfB1B1s4sMc-unsplash.jpg)

Checking my filesystem, I can see the images are there in both folders:

For width 2000:

```auto
ls -al content/images/size/w2000/2022/04
total 436
drwxrwxr-x 2 ghost ghost 4096 Oct 6 10:51 .
drwxrwxr-x 9 ghost ghost 4096 Oct 6 10:51 ..
-rw-rw-r-- 1 ghost ghost 224084 Oct 6 10:52 christin-hume-mfB1B1s4sMc-unsplash.jpg
-rw-rw-r-- 1 ghost ghost 209068 Oct 6 10:52 christopher-gower-m_HRfLhgABo-unsplash.jpg

```

For width 600:

```auto
ls -al content/images/size/w600/2022/04
total 72
drwxrwxr-x 2 ghost ghost 4096 Oct 6 10:51 .
drwxrwxr-x 9 ghost ghost 4096 Oct 6 10:51 ..
-rw-rw-r-- 1 ghost ghost 30727 Oct 6 10:52 christin-hume-mfB1B1s4sMc-unsplash.jpg
-rw-rw-r-- 1 ghost ghost 30916 Oct 6 10:52 christopher-gower-m_HRfLhgABo-unsplash.jpg

```

Above these directories I’ve already checked that the owner is correct, everything is under `ghost:ghost`:

```auto
ls -al
total 64
drwxr-xr-x 6 jose jose 4096 Oct 7 08:09 .
drwxr-xr-x 6 root root 4096 Sep 29 13:00 ..
-rw-rw-r-- 1 jose jose 201 Oct 7 08:09 .ghost-cli
-rw-rw-r-- 1 jose jose 1400 Oct 7 08:28 config.production.json
drwxrwxr-x 12 ghost ghost 4096 Oct 6 13:05 content
lrwxrwxrwx 1 jose jose 34 Oct 7 08:09 current -> /var/www/ghost-new/versions/5.17.2
drwxrwxr-x 122 jose jose 4096 Oct 6 13:06 node_modules
-rw-rw-r-- 1 jose jose 69 Oct 6 13:04 package.json
drwxrwxr-x 3 jose jose 4096 Sep 29 13:03 system
drwxrwxr-x 4 jose jose 4096 Oct 7 08:08 versions
-rw-rw-r-- 1 jose jose 25517 Oct 6 13:04 yarn.lock

```

```auto
ls -al content/images
total 36
drwxrwxr-x 9 ghost ghost 4096 Oct 6 10:52 .
drwxrwxr-x 12 ghost ghost 4096 Oct 6 13:05 ..
drwxrwxr-x 6 ghost ghost 4096 Dec 6 2017 2017
drwxrwxr-x 8 ghost ghost 4096 Nov 14 2018 2018
drwxrwxr-x 13 ghost ghost 4096 Dec 5 2019 2019
drwxrwxr-x 6 ghost ghost 4096 Oct 6 10:52 2020
drwxrwxr-x 8 ghost ghost 4096 Oct 6 10:52 2021
drwxrwxr-x 10 ghost ghost 4096 Oct 6 13:11 2022
drwxrwxr-x 7 ghost ghost 4096 Sep 29 13:13 size

```

```auto
ls -al content/images/size
total 28
drwxrwxr-x 7 ghost ghost 4096 Sep 29 13:13 .
drwxrwxr-x 9 ghost ghost 4096 Oct 6 10:52 ..
drwxrwxr-x 7 ghost ghost 4096 Oct 6 10:51 w100
drwxrwxr-x 7 ghost ghost 4096 Oct 6 10:51 w1000
drwxrwxr-x 7 ghost ghost 4096 Oct 6 10:51 w2000
drwxrwxr-x 3 ghost ghost 4096 Sep 29 13:13 w256h256
drwxrwxr-x 7 ghost ghost 4096 Oct 6 10:51 w600

```

```auto
ls -al content/images/size/w2000
total 28
drwxrwxr-x 7 ghost ghost 4096 Oct 6 10:51 .
drwxrwxr-x 7 ghost ghost 4096 Sep 29 13:13 ..
drwxrwxr-x 6 ghost ghost 4096 Oct 4 16:37 2018
drwxrwxr-x 13 ghost ghost 4096 Oct 4 14:04 2019
drwxrwxr-x 6 ghost ghost 4096 Oct 6 10:51 2020
drwxrwxr-x 8 ghost ghost 4096 Oct 6 10:51 2021
drwxrwxr-x 9 ghost ghost 4096 Oct 6 10:51 2022

```

Anyway I checked them all, it’s all `ghost:ghost`.

## Deviation from the standard install

In my `config.production.json` I’ve got this:

```json
"imageOptimization": {
  "resize": false
}

```

Because I’m using the `ghost-storage-cloudinary` storage adapter (which does seem to work on new image uploads). However, [as far as I can see in the documentation](https://ghost.org/docs/config/#image-optimisation), setting `resize: false` only affects image upload to Ghost, and not image serving. The images under `w2000` and `w600` (and others) were uploaded to Ghost before I started using the cloudinary storage adapter.

FWIW, this is my theme’s code for the image:

```html
<img class="post-card-image"
    srcset="{{img_url feature_image size="m"}} 600w,
            {{img_url feature_image size="l"}} 1000w,
            {{img_url feature_image size="xl"}} 2000w"
    sizes="(max-width: 1000px) 400px, 700px"
    src="{{img_url feature_image size="m"}}"
    alt="{{title}}"
/>

```

Could you give me a hand with this issue?

- I would expect the image at w600 to be served (especially since it’s there in the filesystem!).
- Failing that, I would expect the base image not to return 404, since it’s also there in the path `/content/images/2022/04/christin-hume-mfb1b1s4smc-unsplash.jpg`

Thank you!

Jose

---

<div class="post-metadata">

**Author:** ![jslvtr](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jslvtr/32/3273_2.png) [@jslvtr](https://forum.ghost.org/u/jslvtr)\
**Post date:** [October 12, 2022, 12:10pm UTC](https://forum.ghost.org/t/some-image-sizes-returning-302-followed-by-404/33277/2 "2022-10-12T12:10:45Z")

</div>

Bump! Any ideas on what could be going wrong?  
Thank you!

---

<div class="post-metadata">

**Author:** ![jslvtr](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/jslvtr/32/3273_2.png) [@jslvtr](https://forum.ghost.org/u/jslvtr)\
**Post date:** [October 13, 2022, 11:07am UTC](https://forum.ghost.org/t/some-image-sizes-returning-302-followed-by-404/33277/3 "2022-10-13T11:07:51Z")

</div>

After much investigation, it seems the problem is caused by the storage adapter: [GitHub - eexit/ghost-storage-cloudinary: A fully-featured and deeply tested Cloudinary Ghost storage adapter](https://github.com/eexit/ghost-storage-cloudinary)

When an image that already exists in the filesystem but not in Cloudinary is requested, it doesn’t fall back to the filesystem and causes this weird 301 → 404 redirection.

I’ve raised an issue with them: [Images uploaded before activating this adapter return 404 · Issue #152 · eexit/ghost-storage-cloudinary · GitHub](https://github.com/eexit/ghost-storage-cloudinary/issues/152)
