Skip to content
Extraits de code Groupes Projets
Valider 1b2440f6 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

we now store image height and width locally; still need to federate the values

parent b4d50510
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -20,5 +20,11 @@ class UnprocessedImage < CarrierWave::Uploader::Base ...@@ -20,5 +20,11 @@ class UnprocessedImage < CarrierWave::Uploader::Base
version :thumb_small version :thumb_small
version :thumb_medium version :thumb_medium
version :thumb_large version :thumb_large
version :scaled_full version :scaled_full do
process :get_version_dimensions
end
def get_version_dimensions
model.width, model.height = `identify -format "%wx%h" #{file.path}`.split(/x/)
end
end end
class AddWidthAndHeightToPhotos < ActiveRecord::Migration
def change
add_column :photos, :height, :integer
add_column :photos, :width, :integer
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120414005431) do ActiveRecord::Schema.define(:version => 20120420185823) do
create_table "account_deletions", :force => true do |t| create_table "account_deletions", :force => true do |t|
t.string "diaspora_handle" t.string "diaspora_handle"
...@@ -297,6 +297,8 @@ ActiveRecord::Schema.define(:version => 20120414005431) do ...@@ -297,6 +297,8 @@ ActiveRecord::Schema.define(:version => 20120414005431) do
t.string "unprocessed_image" t.string "unprocessed_image"
t.string "status_message_guid" t.string "status_message_guid"
t.integer "comments_count" t.integer "comments_count"
t.integer "height"
t.integer "width"
end end
add_index "photos", ["status_message_guid"], :name => "index_photos_on_status_message_guid" add_index "photos", ["status_message_guid"], :name => "index_photos_on_status_message_guid"
......
...@@ -125,7 +125,11 @@ describe Photo do ...@@ -125,7 +125,11 @@ describe Photo do
context 'with a saved photo' do context 'with a saved photo' do
before do before do
UnprocessedImage.enable_processing = true
@photo.unprocessed_image.store! File.open(@fixture_name) @photo.unprocessed_image.store! File.open(@fixture_name)
UnprocessedImage.enable_processing = false
end end
it 'should have text' do it 'should have text' do
@photo.text= "cool story, bro" @photo.text= "cool story, bro"
...@@ -145,6 +149,12 @@ describe Photo do ...@@ -145,6 +149,12 @@ describe Photo do
@photo.url.include?(@fixture_filename).should be false @photo.url.include?(@fixture_filename).should be false
@photo.url(:thumb_medium).include?("/" + @fixture_filename).should be false @photo.url(:thumb_medium).include?("/" + @fixture_filename).should be false
end end
it 'should save the image dimensions' do
@photo.width.should == 40
@photo.height.should == 40
end
end end
describe 'non-image files' do describe 'non-image files' do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter