Confused by sizes

12 views
Skip to first unread message

John Whitmore

unread,
Aug 6, 2016, 7:08:38 AM8/6/16
to Django Photologue
I've added photologue to my zinnai based blogging site so that I can upload photos to my media directory and then refer to them in blog posts.

I'm confused by how sizes are implemented. I have an original photo of size 1600x1200 but if I only want to display it in a blog post at a size of 400x300 I define a new size in photologue of 400x300. I don't want the image cropped, just resized. So now I have an image and a size in photologue but I can't find how I refer to that image at a requested size in an html "img" tag.

Been looking through documentation and can't find any mention of that aspect of operation. Any advice would be great.

Richard Barran

unread,
Aug 6, 2016, 8:40:25 AM8/6/16
to django-p...@googlegroups.com
Hi John,

I think that this crucial information is missing from the documentation and will need adding :-)

Each Photo instance has a method get_<size>_url() where <size> is the name of the PhotoSize that you have defined in Photologue.

Hope to help,
Richard

--
You received this message because you are subscribed to the Google Groups "Django Photologue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-photolo...@googlegroups.com.
To post to this group, send email to django-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-photologue.
For more options, visit https://groups.google.com/d/optout.

John Whitmore

unread,
Aug 6, 2016, 9:19:37 AM8/6/16
to Django Photologue
Hi Richard,

Thanks a million for getting back to me. I've got that from Internet searches but struggling to "wire" that up. In my blog post I was trying something like:

<img src="{% get_blog_post_url() %}/photo.png"/>

But I'm doing that in a zinnai blog post so might have to add another line to the top of the template.

John Whitmore

unread,
Aug 6, 2016, 1:01:56 PM8/6/16
to Django Photologue
Looking into this a bit more I need to add a new URL to photologue's urls.py and a view which is in the form:

photologue/size/photo

that would simply return the image file in /media/photologue

John Whitmore

unread,
Aug 6, 2016, 7:01:48 PM8/6/16
to Django Photologue
Got it. Added my own line to my own urls.py

    url(r'^blog_photo/(\w+)/', blog_photo),

And then in my views

def blog_photo(request, requested_slug):
    logger.debug("photo_blog_post request for %s" % (requested_slug))

    photo = Photo.objects.get(slug=requested_slug)
    url = photo.get_blog_post_url()

    logger.debug("URL %s" % (url,))

    return redirect(url)
Reply all
Reply to author
Forward
0 new messages