Skip to content

Commit 4b0c636

Browse files
Replace via.placeholder.com with placehold.co
Fixes #3055 I also removed the word `random` from `Produces a random placeholder image`
1 parent 3b6efaf commit 4b0c636

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

doc/default/omniauth.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Faker::Omniauth.github #=>
215215
:nickname => "jackson-keeling",
216216
:email => "jackson.keeling@example.com",
217217
:name => "Jackson Keeling",
218-
:image => "https://via.placeholder.com/300x300.png",
218+
:image => "https://placehold.co/300x300.png",
219219
:urls => {
220220
:GitHub => "https://github.com/jackson-keeling"
221221
}
@@ -228,7 +228,7 @@ Faker::Omniauth.github #=>
228228
:raw_info => {
229229
:login => "jackson-keeling",
230230
:id => "95144751",
231-
:avatar_url => "https://via.placeholder.com/300x300.png",
231+
:avatar_url => "https://placehold.co/300x300.png",
232232
:gravatar_id => "",
233233
:url => "https://api.github.com/users/jackson-keeling",
234234
:html_url => "https://github.com/jackson-keeling",
@@ -299,7 +299,7 @@ Faker::Omniauth.auth0 #=>
299299
:name => "auth0|d0584e3ab2d3816be9518a56",
300300
:nickname => "Thurman DuBuque",
301301
:email => "dubuque_thurman@example.com",
302-
:image => "https://via.placeholder.com/300x300.png"
302+
:image => "https://placehold.co/300x300.png"
303303
},
304304
:credentials=> {
305305
:expires_at => 1654345109,

doc/default/placeholdit.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
```ruby
44
# Keyword arguments: size, format, background_color, text_color, text
5-
Faker::Placeholdit.image #=> "https://via.placeholder.com/300x300.png"
6-
Faker::Placeholdit.image(size: '50x50') #=> "https://via.placeholder.com/50x50.png"
7-
Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://via.placeholder.com/50x50.jpg"
8-
Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://via.placeholder.com/50x50.gif/ffffff"
9-
Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://via.placeholder.com/50x50.jpeg/39eba7"
10-
Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://via.placeholder.com/50x50.jpeg/ffffff/000"
11-
Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text"
5+
Faker::Placeholdit.image #=> "https://placehold.co/300x300.png"
6+
Faker::Placeholdit.image(size: '50x50') #=> "https://placehold.co/50x50.png"
7+
Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://placehold.co/50x50.jpg"
8+
Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://placehold.co/50x50.gif/ffffff"
9+
Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://placehold.co/50x50.jpeg/39eba7"
10+
Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://placehold.co/50x50.jpeg/ffffff/000"
11+
Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://placehold.co/50x50.jpg/ffffff/000?text=Some Custom Text"
1212
```
1313

1414
## Tips

lib/faker/default/placeholdit.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class << self
66
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze
77

88
##
9-
# Produces a random placeholder image from https://via.placeholder.com.
9+
# Produces a random placeholder image from https://placehold.co.
1010
#
1111
# @param size [String] Specifies the image's size, dimensions separated by 'x'.
1212
# @param format [String] Specifies the image's extension.
@@ -17,13 +17,13 @@ class << self
1717
#
1818
# @example
1919
# # Keyword arguments: size, format, background_color, text_color, text
20-
# Faker::Placeholdit.image #=> "https://via.placeholder.com/300x300.png"
21-
# Faker::Placeholdit.image(size: '50x50') #=> "https://via.placeholder.com/50x50.png"
22-
# Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://via.placeholder.com/50x50.jpg"
23-
# Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://via.placeholder.com/50x50.gif/ffffff"
24-
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://via.placeholder.com/50x50.jpeg/39eba7"
25-
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://via.placeholder.com/50x50.jpeg/ffffff/000"
26-
# Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://via.placeholder.com/50x50.jpg/ffffff/000?text=Some Custom Text"
20+
# Faker::Placeholdit.image #=> "https://placehold.co/300x300.png"
21+
# Faker::Placeholdit.image(size: '50x50') #=> "https://placehold.co/50x50.png"
22+
# Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://placehold.co/50x50.jpg"
23+
# Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://placehold.co/50x50.gif/ffffff"
24+
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://placehold.co/50x50.jpeg/39eba7"
25+
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://placehold.co/50x50.jpeg/ffffff/000"
26+
# Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://placehold.co/50x50.jpg/ffffff/000?text=Some Custom Text"
2727
#
2828
# @faker.version 1.6.0
2929
def image(size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
@@ -35,7 +35,7 @@ def image(size: '300x300', format: 'png', background_color: nil, text_color: nil
3535
raise ArgumentError, "background_color must be a hex value without '#'" unless background_color.nil? || background_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/
3636
raise ArgumentError, "text_color must be a hex value without '#'" unless text_color.nil? || text_color =~ /((?:^\h{3}$)|(?:^\h{6}$)){1}(?!.*\H)/
3737

38-
image_url = "https://via.placeholder.com/#{size}.#{format}"
38+
image_url = "https://placehold.co/#{size}.#{format}"
3939
image_url += "/#{background_color}" if background_color
4040
image_url += "/#{text_color}" if text_color
4141
image_url += "?text=#{text}" if text

test/faker/default/test_placeholdit.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def setup
88
end
99

1010
def test_placeholdit
11-
refute_nil @tester.image.match(%r{https://via\.placeholder\.com/(.+)(png?)})[1]
11+
refute_nil @tester.image.match(%r{https://placehold\.co/(.+)(png?)})[1]
1212
end
1313

1414
def test_avatar_with_custom_size
15-
assert_equal('3x3', @tester.image(size: '3x3').match(%r{https://via\.placeholder\.com/+(\d+x\d+)})[1])
15+
assert_equal('3x3', @tester.image(size: '3x3').match(%r{https://placehold\.co/+(\d+x\d+)})[1])
1616
end
1717

1818
def test_avatar_with_incorrect_size
@@ -22,7 +22,7 @@ def test_avatar_with_incorrect_size
2222
end
2323

2424
def test_avatar_with_supported_format
25-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)}, @tester.image(size: '300x300', format: 'jpg')
25+
assert_match %r{https://placehold\.co/(.+)(jpg?)}, @tester.image(size: '300x300', format: 'jpg')
2626
end
2727

2828
def test_avatar_with_incorrect_format
@@ -32,15 +32,15 @@ def test_avatar_with_incorrect_format
3232
end
3333

3434
def test_avatar_background_with_correct_six_char_hex
35-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)/ffffff}, @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff')
35+
assert_match %r{https://placehold\.co/(.+)(jpg?)/ffffff}, @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff')
3636
end
3737

3838
def test_avatar_background_with_correct_three_char_hex
39-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)/fff}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff')
39+
assert_match %r{https://placehold\.co/(.+)(jpg?)/fff}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff')
4040
end
4141

4242
def test_avatar_background_with_random_color
43-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)/[a-f0-9]{6}}, @tester.image(size: '300x300', format: 'jpg', background_color: :random)
43+
assert_match %r{https://placehold\.co/(.+)(jpg?)/[a-f0-9]{6}}, @tester.image(size: '300x300', format: 'jpg', background_color: :random)
4444
end
4545

4646
def test_avatar_background_with_wrong_six_char_hex
@@ -62,15 +62,15 @@ def test_avatar_background_with_wrong_three_char_hex
6262
end
6363

6464
def test_avatar_font_color_with_correct_six_char_hex
65-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)/ffffff/000000}, @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff', text_color: '000000')
65+
assert_match %r{https://placehold\.co/(.+)(jpg?)/ffffff/000000}, @tester.image(size: '300x300', format: 'jpg', background_color: 'ffffff', text_color: '000000')
6666
end
6767

6868
def test_avatar_font_color_with_correct_three_char_hex
69-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)/fff}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000')
69+
assert_match %r{https://placehold\.co/(.+)(jpg?)/fff}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000')
7070
end
7171

7272
def test_avatar_font_color_with_random_color
73-
assert_match %r{https://via\.placeholder\.com/(.+)(jpg?)/fff/[a-f0-9]{6}}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: :random)
73+
assert_match %r{https://placehold\.co/(.+)(jpg?)/fff/[a-f0-9]{6}}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: :random)
7474
end
7575

7676
def test_avatar_font_color_with_wrong_six_char_hex
@@ -92,10 +92,10 @@ def test_avatar_font_color_with_wrong_three_char_hex
9292
end
9393

9494
def test_text_not_present
95-
assert_match %r{https://via\.placeholder\.com/[^\\?]+$}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000')
95+
assert_match %r{https://placehold\.co/[^\\?]+$}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000')
9696
end
9797

9898
def test_text_present
99-
assert_match %r{https://via\.placeholder\.com/(.+)\?text=hello}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000', text: 'hello')
99+
assert_match %r{https://placehold\.co/(.+)\?text=hello}, @tester.image(size: '300x300', format: 'jpg', background_color: 'fff', text_color: '000', text: 'hello')
100100
end
101101
end

0 commit comments

Comments
 (0)