2

I have a list of hundreds of festivals and I'm trying to determine how to effectively use an if statement to test when:

this type of page - http://www1.sk-static.com/images/media/profile_images/events/18704054/col4

is different than this

this type of page - http://www2.sk-static.com/images/media/profile_images/events/18709809/col4

As you can see in the the top link, there is no image, but actually there is... it is a blank image. I have a back-up image in this case but I can't seem to figure out how to test if the image is blank or not since both links are valid with 'images' on them.

craig_h
  • 31,871
  • 6
  • 59
  • 68
  • 4
    can we see some code? – SomeKittens Jun 05 '14 at 04:27
  • There isn't much code to show here other than:
    . Where festival.fest_icon is the link(s) above. I suppose I could test the size of the image in Ruby/Rails before saving it to the table. But maybe client side is better, dunno yet
    – whoaaallamapajama Jun 05 '14 at 17:13

2 Answers2

1

You can test the memory size of the image, if you are using any server side scripting language.

as i can see from you above images first image(blank) is of size 237 Bytes where as second image is of size 87.9 KB

as blank image size is less you can check the size and show alternative image.

see this question this may help you

determining image file size dimensions via javascript

Community
  • 1
  • 1
ashok_p
  • 741
  • 3
  • 8
  • 17
  • That could work, but the images are really just saved as string, they don't appear until on the client side. I don't see anyway for JS to compute size only width, height, naturalWidth, naturalHeight – whoaaallamapajama Jun 05 '14 at 23:10
  • how do you fetch the images? is it from database? – ashok_p Jun 06 '14 at 04:13
0

You can test for the image name which is blank image and obviously this image will be where the blank image would be. So if you get background image with such name apply your condition.

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231