public static function generate_no_image()
    {
        // See if the image is already in the DB
        $no_image = "no-image.png";
        $image = File::find($no_image);

        // If not, create new record
        if (!isset($image)) {
            $reflector = new ReflectionClass(self::class);
            $curr_file = dirname($reflector->getFileName());
            $curr_file = str_replace(
                "src/helpers",
                "client/dist/images/no-image.png",
                $curr_file
            );

            $config = array(
                'conflict' => AssetStore::CONFLICT_OVERWRITE,
                'visibility' => AssetStore::VISIBILITY_PUBLIC
            );
            
            $image = Injector::inst()->create(Image::class);
            $image->setFromLocalFile(
                $curr_file,
                $no_image,
                null,
                null,
                $config
            );
            $image->write();
            $image->publishSingle();
        }

        return $image;
    }
public static function generate_no_image()
    {
        // See if the image is already in the DB
        $no_image = "no-image.png";
        $image = File::find($no_image);

        // If not, create new record
        if (!isset($image)) {
            $reflector = new ReflectionClass(self::class);
            $curr_file = dirname($reflector->getFileName());
            $curr_file = str_replace(
                "src/helpers",
                "client/dist/images/no-image.png",
                $curr_file
            );

            $config = array(
                'conflict' => AssetStore::CONFLICT_OVERWRITE,
                'visibility' => AssetStore::VISIBILITY_PUBLIC
            );
            
            $image = Injector::inst()->create(Image::class);
            $image->setFromLocalFile(
                $curr_file,
                $no_image,
                null,
                null,
                $config
            );
            $image->write();
            $image->publishSingle();
        }

        return $image;
    }
public static function generate_no_image ( ) { // See if the image is already in the DB $ no_image = "no-image.png" ; $ image = File :: find ( $ no_image ) ; // If not, create new record if ( ! isset ( $ image ) ) { $ reflector = new ReflectionClass ( self :: class ) ; $ curr_file = dirname ( $ reflector -> getFileName ( ) ) ; $ curr_file = str_replace ( "src/helpers" , "client/dist/images/no-image.png" , $ curr_file ) ; $ config = array ( 'conflict' => AssetStore :: CONFLICT_OVERWRITE , 'visibility' => AssetStore :: VISIBILITY_PUBLIC ) ; $ image = Injector :: inst ( ) -> create ( Image :: class ) ; $ image -> setFromLocalFile ( $ curr_file , $ no_image , null , null , $ config ) ; $ image -> write ( ) ; $ image -> publishSingle ( ) ; } return $ image ; }
Copy the default no product image from this module and then
add a new image to the DB.

Returns the new image, so it can be assigned
Copy the default no product image from this module and then add a new image to the DB .