Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-catalog
Block
Product
ImageBuilder.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\Catalog\Block\Product
;
9
10
use Magento\Catalog\Helper\ImageFactory as HelperFactory;
11
use
Magento\Catalog\Model\Product
;
12
17
class
ImageBuilder
18
{
22
protected
$imageFactory
;
23
27
protected
$helperFactory
;
28
32
protected
$product
;
33
37
protected
$imageId
;
38
42
protected
$attributes
= [];
43
48
public
function
__construct
(
49
HelperFactory
$helperFactory
,
50
ImageFactory
$imageFactory
51
) {
52
$this->helperFactory =
$helperFactory
;
53
$this->imageFactory =
$imageFactory
;
54
}
55
62
public
function
setProduct
(
Product
$product
)
63
{
64
$this->product =
$product
;
65
return
$this;
66
}
67
74
public
function
setImageId
(
$imageId
)
75
{
76
$this->imageId =
$imageId
;
77
return
$this;
78
}
79
86
public
function
setAttributes
(array
$attributes
)
87
{
88
$this->attributes =
$attributes
;
89
return
$this;
90
}
91
97
protected
function
getCustomAttributes
()
98
{
99
$result
= [];
100
foreach
($this->attributes as
$name
=>
$value
) {
101
$result
[] =
$name
.
'="'
.
$value
.
'"'
;
102
}
103
return
!empty(
$result
) ? implode(
' '
,
$result
) :
''
;
104
}
105
112
protected
function
getRatio
(\
Magento
\Catalog\
Helper
\
Image
$helper
)
113
{
114
$width =
$helper
->getWidth();
115
$height =
$helper
->getHeight();
116
if
($width && $height) {
117
return
$height / $width;
118
}
119
return
1;
120
}
121
130
public
function
create
(
Product
$product
=
null
,
string
$imageId
=
null
, array
$attributes
=
null
)
131
{
132
$product
=
$product
??
$this->product
;
133
$imageId
=
$imageId
??
$this->imageId
;
134
$attributes
=
$attributes
??
$this->attributes
;
135
return
$this->imageFactory->create(
$product
,
$imageId
,
$attributes
);
136
}
137
}
$result
$result
Definition:
product_configurable_not_available_rollback.php:26
Magento\Catalog\Block\Product\ImageBuilder
Definition:
ImageBuilder.php:17
$helper
$helper
Definition:
iframe.phtml:13
Magento\Catalog\Block\Product\ImageBuilder\$imageFactory
$imageFactory
Definition:
ImageBuilder.php:22
Magento\Catalog\Block\Product\ImageBuilder\create
create(Product $product=null, string $imageId=null, array $attributes=null)
Definition:
ImageBuilder.php:130
Magento\Catalog\Block\Product\ImageBuilder\$imageId
$imageId
Definition:
ImageBuilder.php:37
Magento\Catalog\Block\Product\ImageFactory
Definition:
ImageFactory.php:22
Magento\Catalog\Block\Product\ImageBuilder\setAttributes
setAttributes(array $attributes)
Definition:
ImageBuilder.php:86
Magento\Catalog\Block\Product
Definition:
AbstractTest.php:6
Magento\Catalog\Block\Product\ImageBuilder\getCustomAttributes
getCustomAttributes()
Definition:
ImageBuilder.php:97
Magento\Catalog\Block\Product\ImageBuilder\getRatio
getRatio(\Magento\Catalog\Helper\Image $helper)
Definition:
ImageBuilder.php:112
Magento\Catalog\Block\Product\ImageBuilder\$attributes
$attributes
Definition:
ImageBuilder.php:42
$value
$value
Definition:
gender.phtml:16
Magento\Catalog\Block\Product\ImageBuilder\$helperFactory
$helperFactory
Definition:
ImageBuilder.php:27
Magento\Catalog\Model\Product
Definition:
Product.php:42
Magento\Catalog\Block\Product\ImageBuilder\__construct
__construct(HelperFactory $helperFactory, ImageFactory $imageFactory)
Definition:
ImageBuilder.php:48
Magento\Catalog\Model\Product
Definition:
ActionTest.php:6
Magento\Catalog\Block\Product\ImageBuilder\$product
$product
Definition:
ImageBuilder.php:32
Magento\Catalog\Block\Product\ImageBuilder\setProduct
setProduct(Product $product)
Definition:
ImageBuilder.php:62
Magento
Magento\Catalog\Model\ResourceModel\Helper
Definition:
Helper.php:11
Magento\Catalog\Block\Product\Image
Definition:
Image.php:18
Magento\Catalog\Block\Product\ImageBuilder\setImageId
setImageId($imageId)
Definition:
ImageBuilder.php:74
$name
if(!isset($_GET['name'])) $name
Definition:
log.php:14