Skip to content

Category images in description with {{media url="... #58

@Schrank

Description

@Schrank

You have a regex in `` which tries to get an images from the description if there is no image set on the category. Unfortunately we use {{media url="..." in our descriptions, so the regex doesn't work as expected.

Our current (untested) solution looks like that:

Index: app/code/community/IntegerNet/Solr/Model/Bridge/Category.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/code/community/IntegerNet/Solr/Model/Bridge/Category.php	(revision b4a0f484d1acde29ba8ac970ba260145ead9642f)
+++ app/code/community/IntegerNet/Solr/Model/Bridge/Category.php	(revision ad902853f43cdf6685844fc47786dd42e92cd306)
@@ -7,6 +7,7 @@
  * @copyright  Copyright (c) 2016 integer_net GmbH (http://www.integer-net.de/)
  * @author     Fabian Schmengler <[email protected]>
  */
+
 use IntegerNet\SolrCategories\Implementor\Category;
 use IntegerNet\SolrSuggest\Implementor\SuggestCategory;
 
@@ -141,10 +142,12 @@
             return $imageUrl;
         }
         $content = $this->getDescription();
-        preg_match('/<img.+src=\"(.*)\"/U', $content, $results);
-        if (isset($results[1])) {
+        if(preg_match('/<img.+src=\"\{\{media url=(["\'])(.*?)\1\}\}\"/U', $content, $results)) {
+            return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . '/' . $results[2];
+        } elseif(preg_match('/<img.+src=\"(.*)\"/U', $content, $results)){
             return $results[1];
         }
+
         return '';
     }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions