|
6 | 6 | namespace Magento\Catalog\Helper;
|
7 | 7 |
|
8 | 8 | use Magento\Framework\App\Helper\AbstractHelper;
|
| 9 | +use Magento\Framework\App\ObjectManager; |
9 | 10 |
|
10 | 11 | /**
|
11 | 12 | * Catalog image helper
|
@@ -126,22 +127,31 @@ class Image extends AbstractHelper
|
126 | 127 | */
|
127 | 128 | protected $attributes = [];
|
128 | 129 |
|
| 130 | + /** |
| 131 | + * @var \Magento\Catalog\Model\View\Asset\PlaceholderFactory |
| 132 | + */ |
| 133 | + private $viewAssetPlaceholderFactory; |
| 134 | + |
129 | 135 | /**
|
130 | 136 | * @param \Magento\Framework\App\Helper\Context $context
|
131 | 137 | * @param \Magento\Catalog\Model\Product\ImageFactory $productImageFactory
|
132 | 138 | * @param \Magento\Framework\View\Asset\Repository $assetRepo
|
133 | 139 | * @param \Magento\Framework\View\ConfigInterface $viewConfig
|
| 140 | + * @param \Magento\Catalog\Model\View\Asset\PlaceholderFactory $placeholderFactory |
134 | 141 | */
|
135 | 142 | public function __construct(
|
136 | 143 | \Magento\Framework\App\Helper\Context $context,
|
137 | 144 | \Magento\Catalog\Model\Product\ImageFactory $productImageFactory,
|
138 | 145 | \Magento\Framework\View\Asset\Repository $assetRepo,
|
139 |
| - \Magento\Framework\View\ConfigInterface $viewConfig |
| 146 | + \Magento\Framework\View\ConfigInterface $viewConfig, |
| 147 | + \Magento\Catalog\Model\View\Asset\PlaceholderFactory $placeholderFactory = null |
140 | 148 | ) {
|
141 | 149 | $this->_productImageFactory = $productImageFactory;
|
142 | 150 | parent::__construct($context);
|
143 | 151 | $this->_assetRepo = $assetRepo;
|
144 | 152 | $this->viewConfig = $viewConfig;
|
| 153 | + $this->viewAssetPlaceholderFactory = $placeholderFactory ?: |
| 154 | + ObjectManager::getInstance()->get(\Magento\Catalog\Model\View\Asset\PlaceholderFactory::class); |
145 | 155 | }
|
146 | 156 |
|
147 | 157 | /**
|
@@ -544,14 +554,16 @@ public function getResizedImageInfo()
|
544 | 554 | /**
|
545 | 555 | * @param null|string $placeholder
|
546 | 556 | * @return string
|
547 |
| - * |
548 |
| - * @deprecated Returns only default placeholder. |
549 |
| - * Does not take into account custom placeholders set in Configuration. |
550 | 557 | */
|
551 | 558 | public function getDefaultPlaceholderUrl($placeholder = null)
|
552 | 559 | {
|
553 | 560 | try {
|
554 |
| - $url = $this->_assetRepo->getUrl($this->getPlaceholder($placeholder)); |
| 561 | + $imageAsset = $this->viewAssetPlaceholderFactory->create( |
| 562 | + [ |
| 563 | + 'type' => $placeholder ?: $this->_getModel()->getDestinationSubdir(), |
| 564 | + ] |
| 565 | + ); |
| 566 | + $url = $imageAsset->getUrl(); |
555 | 567 | } catch (\Exception $e) {
|
556 | 568 | $this->_logger->critical($e);
|
557 | 569 | $url = $this->_urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);
|
|
0 commit comments