Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:47:03+00:00 2026-06-10T13:47:03+00:00

I’ve been trying to put a hyperlink on my image thumbnail which would take

  • 0

I’ve been trying to put a hyperlink on my image thumbnail which would take the user to a full size image. but I keep on getting an error.

here as it shows, scribblemedia is a ForeignKey to scribble

models.py

class ScribbleMedia(models.Model):
     media = models.FileField(upload_to=get_file_path)
     def __unicode__(self):
      return self.media
     def find_typecheck(self):
        filename = self.media.name
        try:
           ext = filename.split('.')[-1]
           imgcheck=['jpg','jpeg','png','gif','tiff','bmp']
           if ext in imgcheck :
              chk='image'
           else:
              chk='other'
        except Exception:
           chk='not supported'
        return chk

class Scribble(models.Model):
     title = models.CharField(max_length=120)
     body = models.TextField()
     user = models.ForeignKey(User)
     media = models.ForeignKey(ScribbleMedia)
     def __unicode__(self):
      return u'%s, %s' % (self.user.username, self.media)

views.py

@login_required
def image_page(request,pk):
    img=get_object_or_404(ScribbleMedia,pk=pk)
    image=img.media
    variables= RequestContext(request,{
    'image': image
    })
    return render_to_response('image_page.html',variables)

urls.py

(r"^image/(\d+)/$", image_page),

image_page.html

{% if  image %}
    <img src= {{ image.url }} />

This is the page where the image thumbnail is available

scribble_page.html

{% if scribble.media.media %}
                {% if scribble.media.find_typecheck == 'image' %}
                    {% thumbnail scribble.media.media.url "700x500" crop="center" as im %}
                            <a href="/image/{{ scribble.media.pk }}/" target="_blank"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"></a>
                    {% endthumbnail %}
                {% else %}
                    do something else
                {% endif %}
            {% endif %}

It keeps on giving me the following error:

TemplateSyntaxError at /image/2/
Unclosed tag ‘if’. Looking for one of: elif, else, endif

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:47:05+00:00Added an answer on June 10, 2026 at 1:47 pm

    The if statements in your scribble_page.html are fine. You need to close your if block in your image_page.html template…

    {% if  image %}
      <img src="{{ image.url }}" /> <!-- Also note the added quotations... -->
    {% endif %}  <!-- This is the line you need to add -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I would like to run a str_replace or preg_replace which looks for certain words
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to select an H1 element which is the second-child in its group
I am trying to loop through a bunch of documents I have to put
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.