/** * @param MediaInterface|null $interface * @param File $file * @param string $thumb * @return bool */ protected function createNewImageRecord(MediaInterface $interface = null, File $file, $thumb = '') { if (null === $interface) { return false; } if (false == ($row = $interface->find(['hash' => $file->getHash()]))) { return $interface->insert([$interface->getFieldOriginalName() => $file->getOriginalName(), $interface->getFieldSaveName() => $file->getFilename(), $interface->getFieldSavePath() => $interface, $interface->getFieldThumbnilPath() => $thumb, $interface->getFieldHash() => $file->getHash(), $interface->getFieldSize() => $file->getSize(), $interface->getFieldExt() => $file->getExtension()]); } return $row['id']; }