Image import working

* bundle update
* replacement of image URLs now considers wordpress thumbnails (like -150x150)
* added Guard for autotesting
This commit is contained in:
Marc Remolt
2011-06-13 15:02:40 +02:00
parent 7265d31f62
commit a24ea686fa
11 changed files with 139 additions and 25 deletions

View File

@@ -43,7 +43,12 @@ module Refinery
def replace_image_url_in_blog_posts
::BlogPost.all.each do |post|
if post.body.include? url
post.body = post.body.gsub(url, refinery_image.image.url)
url_parts = url.split('.')
extension = url_parts.pop
url_without_extension = url_parts.join('.')
pattern = /#{url_without_extension}(-\d+x\d+)?\.#{extension}/
post.body = post.body.gsub(pattern, refinery_image.image.url)
post.save!
end
end