1

I imported all of the posts from a WordPress blog, using a regular expression to update the image URLs to their new location in a Craft Asset Source. However, many of the original photos are straight out of the camera - 2000x3000px or whatever. What I would like to do is use that same regex to update them to a transformed version: so /wp-content/uploads/2014/12/photo.jpg would become /media/blog/_fullWidth/photo.jpg. I already set up that replacement and it's working great.

The problem is that the "Full Width" transform hasn't been generated, and just calling the URL from a Rich Text field bypasses Craft, so it never gets generated. Short of manually re-adding every photo through Redactor with the transform, is there any way to force Craft to generate a particular transform on all the images in an asset source?

  • Might be easier (and less processor intensive) in the long run to just download all the images, run them through photoshops 'File>Scripts>Image Processor' in a batch, re-upload them, and update the assets index. – Douglas McDonald Feb 12 '15 at 18:52
  • +1 for Douglas's suggestion. Running all of that through PHP/GD/Imagick is going to be a headache. – Brad Bell Feb 12 '15 at 19:01
2

You could just make a temporary template that makes Craft generate them for you. And depending on how many these are, you better use limit and offset with your craft.assets call.

{% set images = craft.assets.source('myAssetSource').limit(50).offset(0) %}
{% for image in images %}
    <img src="{{ image.url('fullwidth') }}">
{% endfor %}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.