Permalink
Browse files

image plugin improvements

  • Loading branch information...
1 parent 3c8867e commit 28cbd897a9508e1f4e4a7a877361916a1db7c209 @evildmp committed Jan 20, 2012

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,13 +1,20 @@
+from posixpath import join, basename, splitext, exists
+
from django.utils.translation import ugettext_lazy as _
from django.db import models
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes import generic
+from django.utils.translation import ugettext_lazy as _
+from django.conf import settings
+
from cms.models import CMSPlugin, Page
from cms.models.fields import PageField
-from django.utils.translation import ugettext_lazy as _
-from posixpath import join, basename, splitext, exists
+from cms import settings as cms_settings
+
from filer.fields.image import FilerImageField
from filer.fields.file import FilerFileField
-from cms import settings as cms_settings
-from django.conf import settings
+
+from links.models import LinkMethodsMixin
class FilerImage(CMSPlugin):
LEFT = "left"
@@ -55,6 +62,8 @@ class FilerImage(CMSPlugin):
)
float = models.CharField(_("float"), max_length=10, blank=True, null=True, choices=FLOAT_CHOICES)
+
+
'''
@property
def scaled_image_url(self):
@@ -84,6 +93,7 @@ def link(self):
class ImageSetPlugin(CMSPlugin):
IMAGESET_KINDS = (
("basic", "Basic"),
+ ("multiple", "Multiple images"),
("lightbox", "LightBox"),
("slider", "Slider"),
)
@@ -105,12 +115,14 @@ class ImageSetPlugin(CMSPlugin):
(-350.0, u'350 pixels'),
)
),
- ('', u"Image's native width"),
+ ('0', u"Image's native width (use with caution)"),
)
- width = models.FloatField(null=True, blank=True, choices = IMAGE_WIDTHS, default = 1000.0)
- height = models.PositiveIntegerField(null=True, blank=True)
+ width = models.FloatField(choices = IMAGE_WIDTHS, default = 1000.0)
+ height = models.PositiveIntegerField(null=True, blank=True,
+ help_text = "Only applies when <strong>Aspect ratio</strong> is <em>Automatic</em>")
+
ASPECT_RATIOS = (
- (0, u'Native'),
+ (0, u'Automatic'),
(3.0, u'3x1'),
(1.778, u'16x9'),
(1.618, u'Golden ratio (horizonal)'),
@@ -123,24 +135,37 @@ class ImageSetPlugin(CMSPlugin):
(0.563, u'16x9'),
(0.3, u'1x3'),
)
- aspect_ratio = models.FloatField(null=True, choices = ASPECT_RATIOS, default = 0)
+ aspect_ratio = models.FloatField(null=True, choices = ASPECT_RATIOS, default = 0,
+ help_text = "<em>Automatic</em> means native aspect ratio will be used where possible and calculated otherwise")
+
LEFT = "left"
RIGHT = "right"
FLOAT_CHOICES = ((LEFT, _("left")),
(RIGHT, _("right")),
)
float = models.CharField(_("float"), max_length=10, blank=True, null=True, choices=FLOAT_CHOICES)
+ items_per_row = models.PositiveSmallIntegerField(blank = True, null = True,
+ help_text = "Only applies to Multiple and Lightbox plugins")
+
+ @property
+ def items_have_links(self):
+ return all(item.destination_content_object is not None for item in self.imageset_item.all())
+
def __unicode__(self):
return u"image-set-%s" % self.kind
-class ImageSetItem(models.Model):
+class ImageSetItem(models.Model, LinkMethodsMixin):
plugin = models.ForeignKey(ImageSetPlugin, related_name="imageset_item")
image = FilerImageField()
alt_text = models.CharField(null=True, blank=True, max_length=255)
use_description_as_caption = models.BooleanField(verbose_name = "Use description", default=False, help_text = "Use image's description field as caption")
caption = models.TextField(_("Caption"), blank=True, null=True)
+ destination_content_type = models.ForeignKey(ContentType, verbose_name="Type", related_name = "links_to_%(class)s", null = True, blank = True)
+ destination_object_id = models.PositiveIntegerField(verbose_name="Item", null = True, blank = True)
+ destination_content_object = generic.GenericForeignKey('destination_content_type', 'destination_object_id')
+
def __unicode__(self):
if self.image:
return self.image.label
@@ -30,4 +30,4 @@
{% endaddtoblock %}
-<div class="fancybox">{% for item in imageset.items %}<a class='{{ class|default:"fancy" }}' rel='{{ rel|default:"gallery_1" }}' href="{{ item.url}}" title='{{ item.caption|default:"" }}'><img class="fancybox-icon" alt="" src="{% thumbnail item.image icon_size crop subject_location=image.subject_location %}" /></a>{% endfor %}</div>
+<div class="fancybox" style="width: {{ imageset.container_width }}px;">{% for item in imageset.items %}<a class='{{ class|default:"fancy" }}' rel='{{ rel|default:"gallery_1" }}' href="{{ item.large_url}}" title='{{ item.caption|default:"" }}'><img class="fancybox-icon" alt="" src="{% thumbnail item.image imageset.size crop subject_location=image.subject_location %}" /></a>{% endfor %}</div>
@@ -0,0 +1,5 @@
+{% load thumbnail %}
+
+<ul class="multiple-images" style="width: {{ imageset.container_width }}px;">
+{% for item in imageset.items %}<li {% if item.lastinrow %}class="lastinrow"{% endif %}><img alt="" src="{% thumbnail item.image item.icon_size crop subject_location=image.subject_location %}" /></li>{% endfor %}
+</ul>
@@ -1,7 +1,12 @@
-{% load thumbnail filer_tags filer_image_tags %}{% spaceless %}
-<span class = "image {{imageset.float}}"><img alt="{% if imageset_item.alt %}{{ imageset_item.alt }}{% endif %}" class="plugin" src="{% thumbnail imageset_item.image.file image_size crop subject_location=imageset_item.image.subject_location %}" />
- {% if imageset_item.caption %}<span style="width: {{caption_width}}px" class="image_caption">{{ imageset_item.caption }}</span>{% endif %}
- {% if imageset_item.show_author %}
- <span class="image_author">(Author: {{ imageset_item.image.author }})</span>
- {% endif %}
-</span>{% endspaceless %}
+{% load thumbnail filer_tags filer_image_tags %}
+{% spaceless %}
+ <span class = "image {{imageset.float}}">
+ {% if imageset_item.url %}<a href="{{ imageset_item.url }}">{% endif %}
+ <img alt="{% if imageset_item.alt %}{{ imageset_item.alt }}{% endif %}" class="plugin" src="{% thumbnail imageset_item.image.file image_size crop subject_location=imageset_item.image.subject_location %}" />
+ {% if imageset_item.url %}</a>{% endif %}
+ {% if imageset_item.caption %}<span style="width: {{caption_width}}px" class="image_caption">{{ imageset_item.caption }}</span>{% endif %}
+ {% if imageset_item.show_author %}
+ <span class="image_author">(Author: {{ imageset_item.image.author }})</span>
+ {% endif %}
+ </span>
+{% endspaceless %}
@@ -1,7 +1,7 @@
{% load sekizai_tags thumbnail %}
<ul id="{{ imageset|default:"slider"}}">
{% for item in imageset.items %}
- <li><img src="{% thumbnail item.image icon_size crop subject_location=item.image.subject_location %}" alt=""></li>
+ <li><img src="{% thumbnail item.image imageset.size crop subject_location=item.image.subject_location %}" alt=""></li>
{% endfor %}
</ul>
@@ -12,8 +12,8 @@
<link rel="stylesheet" href="{{ STATIC_URL }}slider/css/theme-minimalist-square.css">
<style>
#{{ imageset|default:"slider"}} {
- width: {{ icon_size.0 }}px;
- height: {{ icon_size.1 }}px;
+ width: {{ imageset.size.0 }}px;
+ height: {{ imageset.size.1 }}px;
list-style: none;
/* Prevent FOUC (see FAQ page) and keep things readable if javascript is disabled */
overflow-y: auto;
@@ -27,7 +27,6 @@ def get_placeholder_width(context, plugin):
placeholder_width = context.get("placeholder_width")
placeholder_width = placeholder_width or context.get("width")
placeholder_width = float(placeholder_width or 100.0)
- # placeholder_width = float(context.get("placeholder_width", context.get("width", 100.0)))
# run all registered placeholder_width modifiers
for cls in adjuster_pool.adjusters["placeholder_width"]:
@@ -1,4 +1,12 @@
-/* Navigation Links */
+/* Arkestra image plugin */
+
+ul.multiple-images {padding: 0; margin: 0;}
+ul.multiple-images li {display: inline-block; margin-right: 6px;}
+ul.multiple-images li.lastinrow {margin-right: 0px;}
+
+/* Slider
+
+Navigation Links */
body div.anythingSlider-minimalist-square .anythingControls {
float: right;
position: relative;

0 comments on commit 28cbd89

Please sign in to comment.