I have an if
statement that verifies when <img>
tag is missing dimensions (width
/height
) or if they are blank (width=""
/height=""
), for example:
<img src="http://ift.tt/2k9LMhL" alt="Blank width/height" width="" height="">
<img src="http://ift.tt/2k9LMhL" alt="Blank width" width="">
<img src="http://ift.tt/2k9LMhL" alt="Blank height" height="">
<img src="http://ift.tt/2k9LMhL" alt="No width/height">
The if
statement below works for me. However, I wanted to know if it's possible to simplify the logic that I am using:
if (
# There is no width
! in_array( 'width', $img[1] ) ||
# There is no height
! in_array( 'height', $img[1] ) ||
# The width is blank (width="")
( in_array( 'width', $img[1] ) && in_array( '""', $img[2] ) ) ||
# The height is blank (height="")
( in_array( 'height', $img[1] ) && in_array( '""', $img[2] ) )
) {
# Code here...
}
Aucun commentaire:
Enregistrer un commentaire