Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Picture plugin: Add support for width and height #1520

Closed
wants to merge 3 commits into from

3 participants

@mkoistinen
Owner

Model updated with supporting fields to hold width/height, template now uses same.

@digi604
Collaborator

migrations are missing.

@digi604
Collaborator

and maybe add the widht and hight in a default hidden advanced tab in the form.

@piquadrat
Collaborator

Are we sure we need these fields? Natural width and height are available on the ImageField instance, and if the image needs to be scaled, it's probably a better idea to use something like easy_thumbnails and the width value provided from the placeholder.

@digi604
Collaborator

I close this pull request as i think @piquadrat is right on this one.

@digi604 digi604 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. @mkoistinen

    Update cms/plugins/picture/models.py

    mkoistinen authored
    Added width/height fields to data model
  2. @mkoistinen

    Update cms/plugins/picture/templates/cms/plugins/picture.html

    mkoistinen authored
    Using width and height tags
Commits on Nov 17, 2012
  1. @mkoistinen

    Update cms/plugins/picture/templates/cms/plugins/picture.html

    mkoistinen authored
    Fixed width/height attributes
This page is out of date. Refresh to see the latest.
View
6 cms/plugins/picture/models.py
@@ -1,4 +1,3 @@
-
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ValidationError
@@ -17,7 +16,10 @@ class Picture(CMSPlugin):
(CENTER, _("center")),
)
- image = models.ImageField(_("image"), upload_to=CMSPlugin.get_media_path)
+ image_width = models.PositiveIntegerField("Image_width", blank=True, null=True)
+ image_height = models.PositiveIntegerField("Image_height", blank=True, null=True)
+ image = models.ImageField(_("image"), width_field="image_width",
+ height_field="image_height", upload_to=CMSPlugin.get_media_path)
url = models.CharField(_("link"), max_length=255, blank=True, null=True,
help_text=_("If present, clicking on image will take user to link."))
page_link = models.ForeignKey(Page, verbose_name=_("page"), null=True,
View
2  cms/plugins/picture/templates/cms/plugins/picture.html
@@ -1,5 +1,5 @@
<span class="plugin_picture{% if picture.float %} align-{{ picture.float }}{% endif %}">
{% if link %}<a href="{{ link }}">{% endif %}
-<img src="{{ picture.image.url }}" alt="{{ picture.alt }}"{% if picture.longdesc %} title="{{ picture.longdesc }}"{% endif %} />
+<img src="{{ picture.image.url }}" width="{{ picture.image.width }}" height="{{ picture.image.height }}" alt="{{ picture.alt }}"{% if picture.longdesc %} title="{{ picture.longdesc }}"{% endif %} />
{% if link %}</a>{% endif %}
</span>
Something went wrong with that request. Please try again.