Issue/451 data attribute instead of

Solves #451 by using a data attribute instead of id to identify images.
Replace the magic number and put in an `else` statement, since we don't want this condition evaluated if the previous `if` block condition was true.