Skip to main content
added 13 characters in body
Source Link
Dejo Dekic
  • 909
  • 1
  • 11
  • 28

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution if somebody else needs itthat worked for me:

function is_image( $input ) {
   if ( !empty($input) && getimagesize($input)) {
     return $input;esc_url_raw($input);
   } else {
    return '';
   }
}

If somebody has a better solution please let me know...

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution if somebody else needs it:

function is_image( $input ) {
   if ( !empty($input) && getimagesize($input)) {
     return $input;
   } else {
    return '';
   }
}

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution that worked for me:

function is_image( $input ) {
   if ( !empty($input) && getimagesize($input)) {
     return esc_url_raw($input);
   } else {
    return '';
   }
}

If somebody has a better solution please let me know...

deleted 15 characters in body
Source Link
Dejo Dekic
  • 909
  • 1
  • 11
  • 28

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution if somebody else needs it:

function is_image( $input ) {
   if (file_exists !empty($input) && ($input = getimagesize($input))) {
     return $input;
   } else {
    return '';
   }
}

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution if somebody else needs it:

function is_image( $input ) {
   if (file_exists($input) && ($input = getimagesize($input))) {
     return $input;
   } else {
    return '';
   }
}

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution if somebody else needs it:

function is_image( $input ) {
   if ( !empty($input) && getimagesize($input)) {
     return $input;
   } else {
    return '';
   }
}
Post Undeleted by Dejo Dekic
Post Deleted by Dejo Dekic
Source Link
Dejo Dekic
  • 909
  • 1
  • 11
  • 28

Ok i solved it looks like that getimagesize will generate error/notice if image is not found, so alert box will fire...

This is straight from PHP docs:

If accessing the filename image is impossible getimagesize() will generate an error of level E_WARNING. On read error, getimagesize() will generate an error of level E_NOTICE.

Here is the solution if somebody else needs it:

function is_image( $input ) {
   if (file_exists($input) && ($input = getimagesize($input))) {
     return $input;
   } else {
    return '';
   }
}