# -*- encoding : utf-8 -*-
class ImageContent < ActiveRecord::Base
	belongs_to :image_file

	has_one :portlet, :as => :content, :dependent => :destroy
	STYLES = [["Taille moyenne","1"], ["Petite taille","2"], ["Petit carré","3"], ["Miniature","4"]]
	ALIGNS = [["centré","center"], ["gauche","left"],["droite","right"]]

	belongs_to :cible, :polymorphic => true
	accepts_nested_attributes_for :cible
	
	before_validation do
		if !self.with_cible
			
			self.cible_type = nil
			self.cible_id = nil
		end
	end

	
	
	def url
		
		if self.cible
			cible.url
		else
			""	
		end
		
	end

end
