Ver código fonte

Integrated sorl into templates for dynamic image resizing

master
David Winterbottom 13 anos atrás
pai
commit
0445515a75

+ 1
- 1
oscar/apps/catalogue/abstract_models.py Ver arquivo

293
         return None
293
         return None
294
 
294
 
295
     def primary_image(self):
295
     def primary_image(self):
296
-        images = self.images.all()
296
+        images = self.images.all().order_by('display_order')
297
         if images.count():
297
         if images.count():
298
             return images[0]
298
             return images[0]
299
         return {
299
         return {

+ 9
- 7
oscar/templates/catalogue/partials/gallery.html Ver arquivo

31
                                     <ul>
31
                                     <ul>
32
                                         {% for image in all_images %}
32
                                         {% for image in all_images %}
33
                                             <li>
33
                                             <li>
34
-                                                <a href="{{ image.original.url }}" rel="lightbox">
35
-                                                    <img src="{{ image.original.url }}" data-large="{{ image.original.url }}" alt="image02" data-description="{% if image.caption %}{{ image.caption }}{% endif %}" />
36
-                                                </a>
34
+											{% thumbnail image.original "250x400" upscale=False as thumb %}
35
+                                                <a href="{{ image.original.url }}" rel="lightbox"> <img src="{{ thumb.url }}" data-large="{{ image.original.url }}" alt="image02" data-description="{% if image.caption %}{{ image.caption }}{% endif %}" /> </a>
36
+											{% endthumbnail %}
37
                                             </li>
37
                                             </li>
38
-                                            {% endfor %}
38
+										{% endfor %}
39
                                     </ul>
39
                                     </ul>
40
                             </div>
40
                             </div>
41
                     </div>
41
                     </div>
46
     {% else %}
46
     {% else %}
47
 		{% with image=product.primary_image %}
47
 		{% with image=product.primary_image %}
48
 		    {% thumbnail image.original "400x400" upscale=False as thumb %}
48
 		    {% thumbnail image.original "400x400" upscale=False as thumb %}
49
-			<a href="{{ thumb.url }}" rel="lightbox">
50
-				<img src="{{ thumb.url }}" data-large="{{ image.original.url }}" alt="image02" data-description="{% if image.caption %}{{ image.caption }}{% endif %}" />
51
-			</a>
49
+			{% if not image.is_missing %}
50
+			<a href="{{ image.original.url }}" rel="lightbox"><img src="{{ thumb.url }}" data-large="{{ image.original.url }}" alt="image02" data-description="{% if image.caption %}{{ image.caption }}{% endif %}" /></a>
51
+			{% else %}
52
+			<img src="{{ thumb.url }}" alt="image02" />
53
+			{% endif %}
52
 			{% endthumbnail %}
54
 			{% endthumbnail %}
53
 		{% endwith %}
55
 		{% endwith %}
54
     {% endif %}
56
     {% endif %}

+ 7
- 3
oscar/templates/catalogue/partials/product.html Ver arquivo

1
 {% load currency_filters %}
1
 {% load currency_filters %}
2
 {% load basket_tags %}
2
 {% load basket_tags %}
3
-{% load product_tags %}
3
+{% load thumbnail %}
4
+
4
 <article class="product_pod">
5
 <article class="product_pod">
5
-	{% product_image product as product_image %}
6
     <div class="image_container">
6
     <div class="image_container">
7
-        <a href="{{ product.get_absolute_url }}"><img class="thumbnail" src="{{ product_image.thumbnail_url }}" alt="{{ product.get_title }}"></a>
7
+		{% with image=product.primary_image %}
8
+		{% thumbnail image.original "400x400" upscale=False as thumb %}
9
+		<a href="{{ product.get_absolute_url }}"><img class="thumbnail" src="{{ thumb.url }}" alt="{{ product.get_title }}"></a>
10
+		{% endthumbnail %}
11
+		{% endwith %}
8
     </div>
12
     </div>
9
 
13
 
10
     {% block product_review %}
14
     {% block product_review %}

+ 6
- 9
oscar/templates/reviews/reviews.html Ver arquivo

2
 
2
 
3
 {% load currency_filters %}
3
 {% load currency_filters %}
4
 {% load history_tags %}
4
 {% load history_tags %}
5
+{% load thumbnail %}
5
 
6
 
6
 {% block title %}
7
 {% block title %}
7
 Reviews for {{ product.title }} | {{ block.super }}
8
 Reviews for {{ product.title }} | {{ block.super }}
90
 
91
 
91
         <div class="span3" style="text-align: center">
92
         <div class="span3" style="text-align: center">
92
             <div class="thumbnail">
93
             <div class="thumbnail">
93
-                {% with product.images.all.0 as image %}
94
-                    {% if image %}
95
-                        <a href="{{ image.original.url }}" rel="lightbox">
96
-                            <img src="{{ image.original.url }}" data-large="{{ image.original.url }}" alt="image02" data-description="{% if image.caption %}{{ image.caption }}{% endif %}" />
97
-                            </a>
98
-                        {% else %}
99
-                        <img src="/static/oscar/img/image_not_found.jpg" alt="No image found"/>
100
-                    {% endif %}
101
-                {% endwith %}
94
+				{% with image=product.primary_image %}
95
+				{% thumbnail image.original "400x400" upscale=False as thumb %}
96
+				<a href="{{ product.get_absolute_url }}"><img class="thumbnail" src="{{ thumb.url }}" alt="{{ product.get_title }}"></a>
97
+				{% endthumbnail %}
98
+				{% endwith %}
102
             </div>
99
             </div>
103
             <div>
100
             <div>
104
                 <h2><a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a></h2>
101
                 <h2><a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a></h2>

+ 5
- 10
oscar/templates/search/results.html Ver arquivo

14
 Did you mean <a href="{% url search:search %}?q={{ suggestion }}">{{ suggestion }}</a>?
14
 Did you mean <a href="{% url search:search %}?q={{ suggestion }}">{{ suggestion }}</a>?
15
 {% endif %}
15
 {% endif %}
16
 
16
 
17
-
18
 {% if page.object_list %}
17
 {% if page.object_list %}
19
     <ol class="products vertical three">
18
     <ol class="products vertical three">
20
         {% for result in page.object_list %}
19
         {% for result in page.object_list %}
21
         <li>
20
         <li>
22
             <article class="product_pod">
21
             <article class="product_pod">
23
-            {% for image in result.object.images.all %}
24
-                {% if forloop.first %}
25
-                    {% thumbnail image.original "100" crop="center" as im %}
26
-                    <div class="image_container">
27
-                        <a href="{{ result.object.get_absolute_url }}"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"></a>
28
-                    </div>
29
-                    {% endthumbnail %}
30
-                {% endif %}
31
-            {% endfor %}
22
+			{% with image=product.primary_image %}
23
+			{% thumbnail image.original "400x400" upscale=False as thumb %}
24
+			<a href="{{ product.get_absolute_url }}"><img class="thumbnail" src="{{ thumb.url }}" alt="{{ product.get_title }}"></a>
25
+			{% endthumbnail %}
26
+			{% endwith %}
32
             <h3><a href="{{ result.object.get_absolute_url }}">{{ result.object.get_title }}</a></h3>
27
             <h3><a href="{{ result.object.get_absolute_url }}">{{ result.object.get_title }}</a></h3>
33
             <div class="product_price">
28
             <div class="product_price">
34
                 {% if result.object.is_group %}
29
                 {% if result.object.is_group %}

Carregando…
Cancelar
Salvar