_storeManager = $storeManager; $this->directoryList = $directoryList; $this->io = $io; parent::__construct($context, $registry); } /** * @return void */ protected function _construct() { $this->_init(\Olegnax\Athlete2Slideshow\Model\ResourceModel\Slides::class); } public function getIdentities() { return [$this->_eventPrefix . '_' . $this->getId()]; } private function getPrefixedPath($path, $prefix = '') { $fullPath = ''; $path = ltrim($path, '/'); if (!empty($path)) { $fullPath = $prefix . $path; } return $fullPath; } public function getImageUrl($fieldId = 'image') { return $this->getPrefixedPath($this->getData($fieldId), rtrim((string)$this->_storeManager->getStore()->getBaseUrl( UrlInterface::URL_TYPE_MEDIA), '/') . '/'); } public function getImagePath($fieldId = 'image') { return $this->getPrefixedPath($this->getData($fieldId), $this->directoryList->getRoot() . '/pub/media/'); } public function existsImage($fieldId = 'image') { return is_file($this->getImagePath($fieldId)); } public function hasImage($fieldId = 'image') { return ((bool) $this->getData($fieldId) !== false && $this->existsImage()); } }