Skip to content

Unsecured URLs returned for product images  #35192

Open
@jakwinkler

Description

@jakwinkler

Preconditions (*)

  1. Magento 2.4.2 / 2.4.3
  2. Magento 2.3.x
  3. Multistore installation with following setup:
    -- store nr 1 has different URLs for media
    -- store nr 2 has only secured URL for media different
  4. set secure URLs to be used in frontend

Steps to reproduce (*)

  1. create a CLI method to iterate through all the stores and try to fetch main product image for each store
        /** @var \Magento\Store\Api\Data\StoreInterface $store */
        foreach ($this->storeManager->getStores() as $store) {
            foreach ($this->storeManager->getStores() as $store) {
            // force store emulation for helpers and image getters
            $this->appEmulation->startEnvironmentEmulation($store->getId(), \Magento\Framework\App\Area::AREA_FRONTEND, true);
  1. fetch product collection
  2. display product image using imageHelper class
  3. to make it easier, use the code from sitemap generation
/**
     * Get product image URL from image filename
     *
     * @param string $image
     * @return string
     */
    private function getProductImageUrl(string $image): string
    {
        return $this->imageUrlBuilder->getUrl($image, 'product_page_image_large');
    }

Expected result (*)

  1. image URLs for all product images are per configured URL

Actual result (*)

  1. Media URL for each product is set to the default one

Source of the issue (*)

  1. in this file vendor/magento/module-catalog/Model/Product/Media/Config.php there is no isSecure check
  2. so it returns the same media URLs for all products

Solution (*)

  1. issue can be solved with proper store configuration
  2. introduce code fix to check if secure frontend is used for that media path

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: FrameworkComponent: SitemapIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: dev in progressReported on 2.4.3Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions