Description
(i) This ticket is created automatically based on a verified GitHub issue.
{panel}
If you are starting to work on this Jira ticket, please notify issue reporter and authors of related community pull requests (if any) that you are going to work on this issue:
- Assign #25219 issue to yourself on Magento GitHub
- Add comment "Internal Magento team is working on this issue right now."
{panel}
When using the core product image factory it is no longer possible to add your own custom attributes to the markup produced, due to incorrect escaping of the html output.
######Preconditions
- Install Magento 2.3.3 & 2.3-develop
######Steps to reproduce (*)
- Within a block or viewModel use the \Magento\Catalog\Block\Product\ImageFactory class to create a Magento\Catalog\Block\Product\Image. Set a custom attribute "data-sku" with the value of the product's sku and render the image in a frontend template:
$attributes = <
'data-sku' => $product->getSku()
>;
$image = $this->imageFactory->create($product, $imageId, $attributes);
######Expected result
The image html should render with each of the custom attribute values returned by getCustomAttributes() escaped. In this example <img data-sku="<sku>" />
.
######Actual result (*)
The image renders with the entire getCustomAttributes() string escaped meaning the html is invalid and the attribute is not available on the html element. In this example <img  data-sku="<sku>" />
.
This stems from an over zealous use of escapeHtmlAttr() here: f40f24c#diff-eed94ca7983b385a07b8fb5ee2dbc20d
Metadata
Metadata
Assignees
Labels
Type
Projects
Status