matthewwithanm / django-imagekit

Automated image processing for Django. Currently v4.0
http://django-imagekit.rtfd.org/
BSD 3-Clause "New" or "Revised" License
2.27k stars 275 forks source link

admin thumbnail template rendering with <br/> #249

Open gabbork opened 11 years ago

gabbork commented 11 years ago

hi, when using AdminThumbnail to render thumbs preview in admin (inline in my case), if using default template https://github.com/matthewwithanm/django-imagekit/blob/develop/imagekit/templates/imagekit/admin/thumbnail.html each line is rendered with a < br / > tag (that brakes the layout)

To have the correct rendering I have to provide a all in one line template like this:

{% if thumbnail %}<a href="{{ model.get_absolute_url|default:original_image.url }}"><img src="{{ thumbnail.url }}"></a>{% endif %}

I don't know if I do something incorrect... thanks

matthewwithanm commented 11 years ago

That's odd! Can you share your admin class? Also, which version of Django are you using?

fish2000 commented 11 years ago

I have this problem too – Django is version 1.5.4, freshly installed in a virtualenv.

matthewwithanm commented 11 years ago

@fish2000 Very strange. I can't reproduce this. Can you share the admin class?

alternativshik commented 10 years ago

the same for me. Looks like render_to_string() do it wrong. Latest imagekit from pip Django 1.6

class PhotoAdmin(admin.ModelAdmin):
    list_display = ('title', 'admin_thumbnail')
    readonly_fields = ('admin_thumbnail',)
    admin_thumbnail = AdminThumbnail(
        image_field='thumbnail_s220',
        template='admin/thumbnail.html',
    )

    fieldsets = (
        ('', {
            'classes': ['wide', 'extrapretty'],
            'fields': ('gallery', 'title', 'original', 'admin_thumbnail',
                       'sort', 'is_public'),
        }),
    )