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...