图像显示在铬但不是野生动物园

时间:2018-03-04 02:14:24

标签: javascript d3.js

我试图用图像填充矩形。虽然图片显示在Chrome中,但它们不会出现在Safari中。我没有收到任何错误消息。所以我真的很困惑为什么会这样,请帮助我!或者,如果您可以使用自定义图片填充矩形,我也很高兴收到您的来信!

FURNITURE_SEARCH_FACETS = {
    'fields': OrderedDict([
        ('product_class', {'name': _('Type'), 'field': 'product_class'}),
        ('rating', {'name': _('Rating'), 'field': 'rating'}),

    ]),
    'queries': OrderedDict([
        ('price_range',
         {
             'name': _('Price range'),
             'field': 'price',
             'queries': [
                 # This is a list of (name, query) tuples where the name will
                 # be displayed on the front-end.
                 (_('0 to 20000'), u'[0 TO 20000]'),
                 (_('20000 to 40000'), u'[20000 TO 40000]'),
                 (_('40000 to 60000'), u'[40000 TO 60000]'),
                 (_('60000+'), u'[60000 TO *]'),
             ]
         }),
    ]),
}


class ProductIndex(indexes.SearchIndex, indexes.Indexable):
    # Search text
    text = indexes.CharField(
        document=True, use_template=True,
        template_name='search/indexes/product/item_text.txt')


    name = indexes.EdgeNgramField(model_attr='name', null=True)
    name_exact = indexes.CharField(model_attr='name', null=True, indexed=False)


    # Fields for faceting
    product_class = indexes.CharField(null=True, faceted=True)
    category = indexes.MultiValueField(null=True, faceted=True)
    price = indexes.FloatField(null=True, faceted=True)
    num_in_stock = indexes.IntegerField(null=True, faceted=True)
    rating = indexes.IntegerField(null=True, faceted=True)


    # Spelling suggestions
    suggestions = indexes.FacetCharField()


    date_created = indexes.DateTimeField(model_attr='created_at')
    date_updated = indexes.DateTimeField(model_attr='updated_at')


    _strategy = None


    def get_model(self):
        return get_model('catalogue', 'Product')


    def index_queryset(self, using=None):
        # Only index browsable products (not each individual child product)
        return self.get_model().browsable.order_by('-date_updated')


    def read_queryset(self, using=None):
        return self.get_model().browsable.base_queryset()


    def prepare_product_class(self, obj):
        return obj.get_product_class().name


    def prepare_category(self, obj):
        categories = obj.categories.all()
        if len(categories) > 0:
            return [category.full_name for category in categories]


    def prepare_rating(self, obj):
         if obj.rating is not None:
             return int(obj.rating)


    # Pricing and stock is tricky as it can vary per customer.  However, the
    # most common case is for customers to see the same prices and stock levels
    # and so we implement that case here.


    def get_strategy(self):
        if not self._strategy:
            self._strategy = Selector().strategy()
        return self._strategy


    def prepare_price(self, obj):
        strategy = self.get_strategy()
        result = None
        if obj.is_parent:
            result = strategy.fetch_for_parent(obj)
        elif obj.has_stockrecords:
            result = strategy.fetch_for_product(obj)


        if result:
            if result.price.is_tax_known:
                return result.price.incl_tax
            return result.price.excl_tax


    def prepare_num_in_stock(self, obj):
        strategy = self.get_strategy()
        if obj.is_parent:
            # Don't return a stock level for parent products
            return None
        elif obj.has_stockrecords:
            result = strategy.fetch_for_product(obj)
            return result.stockrecord.net_stock_level


    def prepare(self, obj):
        prepared_data = super(ProductIndex, self).prepare(obj)


        # We use Haystack's dynamic fields to ensure that the title field used
        # for sorting is of type "string'.
        if is_solr_supported():
            prepared_data['name_s'] = prepared_data['name']


        # Use title to for spelling suggestions
        prepared_data['suggestions'] = prepared_data['text']


        return prepared_data

}

2 个答案:

答案 0 :(得分:2)

在对图像使用自定义属性时-Safari以另一种方式解释图像url,例如:

Chrome shows all images, but Safari logs "not allowed to load local resource"

另一个例子:

Chrome doesn't show all images, but Safari works well

问题是方向,我不知道为什么,但是当您使用自定义属性并设置url-野生动物园时,您会在url方向上再添加一个点(“。”)。

答案 1 :(得分:0)

你可以尝试类似的东西 1 .--添加字段!DOCTYPE位于html文档的顶部或

2 .--如果您的图片包含像background-image这样的网址:url(“http://adf.co.us/dm/gs.png”);

然后你必须添加 图像:URL( “http://www.adf.co.us/dm/gs.png”);

我希望它对你有所帮助。