<p>I've also seen this triggered by directory/file permission issues, namely that Craft didn't have write access to the image asset directory. Once I fixed the permissions with chmod, my specific problem was solved.</p>

<pre><code>chmod 777 -R images
</code></pre>

CC BY-SA 3.0
2014-12-15T20:50:58.680Z
2014-12-15T20:50:58.680Z
Alice G.
<p>for me trying the happylager template I had to change access to to site dir</p>

<p><code>chmod  a+w public/assets/site
</code></p>

CC BY-SA 3.0
2017-08-09T03:40:22.343Z
This indicates a server configuration  issue - you should never need to give 'all' write access.  Definitely do not do this in production!
Jeremy Daalder
CC BY-SA 3.0
2017-08-10T09:06:16.043Z
you are right, I had wrong user and group settings.
toy
CC BY-SA 3.0
2017-08-07T15:30:38.647Z
2017-08-07T15:30:38.647Z
toy
<p>I also had this problem and changing the setting worked for me.</p>

<p>I did have a problem where the transforms then showed a 404 page rather than the actual image. Clearing the 'Cache' via settings in Craft CMS fixed this.</p>

CC BY-SA 3.0
2015-12-03T09:33:59.513Z
2015-12-03T09:33:59.513Z
Jason Mayo
<p>I have had the same issue when using a custom function to calculate the image's resulting size.</p>

<p>The problem happened when that function returned decimals. So if you ever calculate the transform's dimensions, make sure you round the results to avoid this.</p>

CC BY-SA 3.0
2016-11-07T13:54:47.133Z
2016-11-07T13:54:47.133Z
yoannisj
<p>That’s what <code>getUrl()</code> returns if the transform hasn’t been generated yet. When the browser requests that URL, Craft will generate the transform, and respond with a 302 redirect to the actual image URL.</p>

<p><em><strong>Update:</strong> As of Craft 2.2, even if the transform generation URL doesn’t get directly requested (e.g. if it’s a social media image, or a <code>srcset</code> size that doesn’t apply to the browser), it will still get generated automatically as a background task as soon as Craft is done serving the page.</em></p>

<p>The next time <code>getUrl()</code> gets called (after the transform has been generated), the image URL will be returned directly.</p>

<p>If you would prefer that <code>getUrl()</code> actually generates the transform itself and immediately returns the image URL (perhaps because the output is getting cached by Varnish or something), you can open up craft/config/general.php and add this to your config array:</p>

<pre><code>'generateTransformsBeforePageLoad' =&gt; true,
</code></pre>

<p>(See <a href="http://buildwithcraft.com/docs/config-settings#generateTransformsBeforePageLoad">http://buildwithcraft.com/docs/config-settings#generateTransformsBeforePageLoad</a> for details.)</p>

CC BY-SA 3.0
2014-07-08T17:10:16.183Z
I'm not caching the output. When the code is loaded by the browser the transformed jpg isn't loaded. The console says: Failed to load resource: the server responded with a status of 404 (Not Found).
FrankFlitton
CC BY-SA 3.0
2014-07-08T17:50:44.283Z
Thanks for the hot tip with the 302 redirect! It was a sources issue. I changed it to `File System Path: ./assets/images/Gallery/` and `URL: /assets/images/Gallery/` in the CP and it works fine now.
FrankFlitton
CC BY-SA 3.0
2014-07-08T19:22:35.953Z
Glad you got it sorted :)
Brandon Kelly
CC BY-SA 3.0
2014-07-08T16:32:45.787Z
2014-10-09T11:08:36.907Z
2014-10-09T11:08:36.907Z
Brandon Kelly
<p>I'm trying to get Craft to render an image transform defined in the control panel. No image is added to the "filelocation/_transformhandle" folder and returns the url "/cpresources/transforms/98" where 98 is the transform index. </p>

<p>I have tried clearing the cache and db table already as well as updating the asset index. I have double checked the sources paths and it is not a file permission issue. </p>

<p>Code example as a matrix block: </p>

<pre><code>{% elseif block.type == "slideShow" %} 
{% if block.galleryImages|length&gt;0 %}

{% for image in block.galleryImages %}
    {{ image.aboutText }}
    &lt;img src="{{ image.getUrl('galleryHorizontal') }}"&gt;
{% endfor %}
{% endif %}
</code></pre>

<p>I tried using the other methods on this page in the docs with the same result. <a href="http://buildwithcraft.com/docs/templating/assetfilemodel">http://buildwithcraft.com/docs/templating/assetfilemodel</a> </p>

<p>Thanks!</p>

CC BY-SA 4.0
2019-08-31T16:17:32.607Z
Still unanswered, and still a longstanding issue for me, is why it is looking in /cpresources/, which I thought meant Control Panel resources, for a photo that is not a Control Panel resource.
David Rhoden
<assets><matrix><image-transforms><url><gallery>
Image transforms returning cpresources url
# Image transforms returning cpresources url

(Asked by: username_0 on 2014-07-08)

I'm trying to get Craft to render an image transform defined in the control panel. No image is added to the "filelocation/_transformhandle" folder and returns the url "/cpresources/transforms/98" where 98 is the transform index. 
I have tried clearing the cache and db table already as well as updating the asset index. I have double checked the sources paths and it is not a file permission issue. 
Code example as a matrix block: 
{% elseif block.type == "slideShow" %} 
{% if block.galleryImages|length>0 %}

{% for image in block.galleryImages %}
    {{ image.aboutText }}
    
{% endfor %}
{% endif %}

I tried using the other methods on this page in the docs with the same result. http://buildwithcraft.com/docs/templating/assetfilemodel 
Thanks!

**Tags:** assets, matrix, image-transforms, url, gallery
> **Comments:**
> **username_1**: Still unanswered, and still a longstanding issue for me, is why it is looking in /cpresources/, which I thought meant Control Panel resources, for a photo that is not a Control Panel resource.  

---

## 5 answers

### Answer by username_7 on 2014-07-08. Score: 21 | Accepted answer

That’s what getUrl() returns if the transform hasn’t been generated yet. When the browser requests that URL, Craft will generate the transform, and respond with a 302 redirect to the actual image URL.
Update: As of Craft 2.2, even if the transform generation URL doesn’t get directly requested (e.g. if it’s a social media image, or a srcset size that doesn’t apply to the browser), it will still get generated automatically as a background task as soon as Craft is done serving the page.
The next time getUrl() gets called (after the transform has been generated), the image URL will be returned directly.
If you would prefer that getUrl() actually generates the transform itself and immediately returns the image URL (perhaps because the output is getting cached by Varnish or something), you can open up craft/config/general.php and add this to your config array:
'generateTransformsBeforePageLoad' => true,

(See http://buildwithcraft.com/docs/config-settings#generateTransformsBeforePageLoad for details.)

> **Comments:**
> **username_0**: I'm not caching the output. When the code is loaded by the browser the transformed jpg isn't loaded. The console says: Failed to load resource: the server responded with a status of 404 (Not Found).  
> **username_0**: Thanks for the hot tip with the 302 redirect! It was a sources issue. I changed it to `File System Path: ./assets/images/Gallery/` and `URL: /assets/images/Gallery/` in the CP and it works fine now.  
> **username_7**: Glad you got it sorted :)  

---

### Answer by username_2 on 2014-12-15. Score: 3

I've also seen this triggered by directory/file permission issues, namely that Craft didn't have write access to the image asset directory. Once I fixed the permissions with chmod, my specific problem was solved.
chmod 777 -R images


---

### Answer by username_3 on 2017-08-07. Score: 1

for me trying the happylager template I had to change access to to site dir

`chmod a+w public/assets/site`

> **Comments:**
> **username_4**: This indicates a server configuration  issue - you should never need to give 'all' write access.  Definitely do not do this in production!  
> **username_3**: you are right, I had wrong user and group settings.  

---

### Answer by username_5 on 2015-12-03. Score: 1

I also had this problem and changing the setting worked for me.

I did have a problem where the transforms then showed a 404 page rather than the actual image. Clearing the 'Cache' via settings in Craft CMS fixed this.


---

### Answer by username_6 on 2016-11-07. Score: 1

I have had the same issue when using a custom function to calculate the image's resulting size.

The problem happened when that function returned decimals. So if you ever calculate the transform's dimensions, make sure you round the results to avoid this.


---

