retina_image_tag 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module RetinaImageTag
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,41 +1,29 @@
1
- require "image_size"
2
-
3
1
  module RetinaImageTag
4
2
  module ViewHelpers
5
3
 
6
4
 
7
5
  def retina_image( pixel_ratio )
8
-
9
- if File.exist?(@rails_image_path+"/"+@file_name+"@#{pixel_ratio}x"+@file_ext)
10
- image_tag(@file_dirname+"/"+@file_name+"@#{pixel_ratio}x"+@file_ext, @options)
11
- else
12
- @normal_image_tag
13
- end
6
+ image_tag(@file_dirname+"/"+@file_name+"@#{pixel_ratio}x"+@file_ext, @options)
14
7
  end
15
8
 
16
9
 
17
10
  def retina_image_tag(image, options = {})
18
11
  @devicePixelRatio = cookies[:devicePixelRatio]
19
12
  @options = options
20
- @rails_image_path = Rails.application.assets.paths.first
21
- @file_path = asset_path(image)
22
- @file_ext = File.extname(@file_path)
23
- @file_name = File.basename(@file_path, @file_ext)
24
- @file_dirname = File.dirname(@file_path)
25
-
26
- if @options[:size] == '@1x'
27
- @options[:size] = ImageSize.path(@rails_image_path+"/"+@file_name+@file_ext).size.to_s
28
- end
29
13
 
30
- @normal_image_tag = image_tag(@file_path, @options)
14
+ @file_path = image_path(image)
15
+ @file_ext = File.extname(@file_path) # .jpg, .png
16
+ @file_name = File.basename(@file_path, @file_ext) # pic1, foo
17
+ @file_dirname = File.dirname(@file_path)
31
18
 
19
+
32
20
  case @devicePixelRatio
33
21
  when '2'
34
22
  retina_image '2'
35
23
  when '1.5'
36
- retina_image '1.5'
24
+ retina_image '2'
37
25
  else
38
- @normal_image_tag
26
+ image_tag(@file_path, @options)
39
27
  end
40
28
  end
41
29
 
@@ -16,7 +16,5 @@ Gem::Specification.new do |gem|
16
16
  gem.version = RetinaImageTag::VERSION
17
17
 
18
18
  gem.add_dependency "railties", "~> 3.1"
19
- gem.add_dependency "image_size", "~> 1.1.0"
20
-
21
19
 
22
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retina_image_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.1'
30
- - !ruby/object:Gem::Dependency
31
- name: image_size
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 1.1.0
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.1.0
46
30
  description: ! 'A high-resolution image is loaded when the retina_image_tag is called
47
31
  from a retina display '
48
32
  email: