public function imageByFilename(&$obj, $val, $record)
    {
        $filename = trim(strtolower(Convert::raw2sql($val)));
        $filenamedashes = str_replace(' ', '-', $filename);
        if ($filename
            && $image = Image::get()->whereAny(
                [
                    "LOWER(\"FileFilename\") LIKE '%$filename%'",
                    "LOWER(\"FileFilename\") LIKE '%$filenamedashes%'"
                ]
            )->first()
        ) { //ignore case
            if ($image instanceof Image && $image->exists()) {
                return $image;
            }
        }
        return null;
    }
public function imageByFilename(&$obj, $val, $record)
    {
        $filename = trim(strtolower(Convert::raw2sql($val)));
        $filenamedashes = str_replace(' ', '-', $filename);
        if ($filename
            && $image = Image::get()->whereAny(
                [
                    "LOWER(\"FileFilename\") LIKE '%$filename%'",
                    "LOWER(\"FileFilename\") LIKE '%$filenamedashes%'"
                ]
            )->first()
        ) { //ignore case
            if ($image instanceof Image && $image->exists()) {
                return $image;
            }
        }
        return null;
    }
public function imageByFilename ( & $ obj , $ val , $ record ) { $ filename = trim ( strtolower ( Convert :: raw2sql ( $ val ) ) ) ; $ filenamedashes = str_replace ( ' ' , '-' , $ filename ) ; if ( $ filename && $ image = Image :: get ( ) -> whereAny ( [ "LOWER(\"FileFilename\") LIKE '%$filename%'" , "LOWER(\"FileFilename\") LIKE '%$filenamedashes%'" ] ) -> first ( ) ) { //ignore case if ( $ image instanceof Image && $ image -> exists ( ) ) { return $ image ; } } return null ; }
set image, based on filename
set image based on filename