Quellcode durchsuchen

Integrated sorl into templates for dynamic image resizing

master
David Winterbottom vor 13 Jahren
Ursprung
Commit
0445515a75

+ 1
- 1
oscar/apps/catalogue/abstract_models.py Datei anzeigen

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

+ 9
- 7
oscar/templates/catalogue/partials/gallery.html Datei anzeigen

@@ -31,11 +31,11 @@
31 31
                                     <ul>
32 32
                                         {% for image in all_images %}
33 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 37
                                             </li>
38
-                                            {% endfor %}
38
+										{% endfor %}
39 39
                                     </ul>
40 40
                             </div>
41 41
                     </div>
@@ -46,9 +46,11 @@
46 46
     {% else %}
47 47
 		{% with image=product.primary_image %}
48 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 54
 			{% endthumbnail %}
53 55
 		{% endwith %}
54 56
     {% endif %}

+ 7
- 3
oscar/templates/catalogue/partials/product.html Datei anzeigen

@@ -1,10 +1,14 @@
1 1
 {% load currency_filters %}
2 2
 {% load basket_tags %}
3
-{% load product_tags %}
3
+{% load thumbnail %}
4
+
4 5
 <article class="product_pod">
5
-	{% product_image product as product_image %}
6 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 12
     </div>
9 13
 
10 14
     {% block product_review %}

+ 6
- 9
oscar/templates/reviews/reviews.html Datei anzeigen

@@ -2,6 +2,7 @@
2 2
 
3 3
 {% load currency_filters %}
4 4
 {% load history_tags %}
5
+{% load thumbnail %}
5 6
 
6 7
 {% block title %}
7 8
 Reviews for {{ product.title }} | {{ block.super }}
@@ -90,15 +91,11 @@ Reviews for {{ product.title }} | {{ block.super }}
90 91
 
91 92
         <div class="span3" style="text-align: center">
92 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 99
             </div>
103 100
             <div>
104 101
                 <h2><a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a></h2>

+ 5
- 10
oscar/templates/search/results.html Datei anzeigen

@@ -14,21 +14,16 @@
14 14
 Did you mean <a href="{% url search:search %}?q={{ suggestion }}">{{ suggestion }}</a>?
15 15
 {% endif %}
16 16
 
17
-
18 17
 {% if page.object_list %}
19 18
     <ol class="products vertical three">
20 19
         {% for result in page.object_list %}
21 20
         <li>
22 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 27
             <h3><a href="{{ result.object.get_absolute_url }}">{{ result.object.get_title }}</a></h3>
33 28
             <div class="product_price">
34 29
                 {% if result.object.is_group %}

Laden…
Abbrechen
Speichern