django-imagekit icon indicating copy to clipboard operation
django-imagekit copied to clipboard

Problem with ImageSpecField

Open laozzzi opened this issue 9 years ago • 9 comments

When you set ImageSpecField at the same time with ImageFiled, ImageField will not work(will not create media folder and will not put uploaded image inside it). But ImageSpecField all the same will reference to 'media/CACHE/....jpg', that does not exist(actually, even 'media' folder doesn't exist).

So it's needed to start project without ImageSpecField at first time, and then add ImageSpecField. Actually, ImageSpecField doesn't check, whether image actually saved or not. It even doesn't check, whether the path exist or not. It just create some link and reference to it. Is this bug?

laozzzi avatar Sep 10 '16 07:09 laozzzi

Can you give us code example of the problem?

vstoykov avatar Sep 15 '16 19:09 vstoykov

I used the same code as in your tutorial.

from django.db import models
from imagekit.models import ImageSpecField
from imagekit.processors import ResizeToFit

class Item(models.Model):
    image = models.ImageField('Image')
    image_thumbnail = ImageSpecField(source='image',
                                      processors=[ResizeToFit(100, 50)],
                                      format='JPEG',
                                      options={'quality': 88})

laozzzi avatar Sep 16 '16 12:09 laozzzi

And with this when you see the error?

vstoykov avatar Sep 16 '16 13:09 vstoykov

It doesn't show error, it just doesn't work. Doesn't create thumbs, doesn't create cache directory. I tried to use "image" application for creating thumbs, and it's worked.16.09.2016, 16:09, "Venelin Stoykov" [email protected]:And with this when you see the error?

—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.

laozzzi avatar Sep 16 '16 14:09 laozzzi

I never experienced such an issue and for that reason I wanted to know more details for your environment.

In your case when you upload an image the file for it is created in media, but when you try to visualize the image in template with:

<img src="{{ item.image_thumbnail.url }}">

you are seeing in the rendered html something like

<img src="/media/CACHE/images/image-name/some-random-characters.JPG">

but you are NOT seeing the image in the browser. Right?

And also if you change the code to {{ item.image.url}} everything is working. Right?

vstoykov avatar Sep 16 '16 21:09 vstoykov

Yes, I am seeing link, but not image. There is not image and at all there is not cache directory. Just an html-link to nowhere. I use now "image" app(https://github.com/francescortiz/image), and it works nice.

laozzzi avatar Sep 24 '16 09:09 laozzzi

I'm experience this aswell on django 1.10, the image thumbnail doesn't get created. No error messages are produced.

silentjay avatar Oct 13 '16 16:10 silentjay

Ok I got it to work using python manage.py generateimages. I was using the Django admin interface to upload the images, is this not supported for ImageSpecField?

silentjay avatar Oct 13 '16 16:10 silentjay

@silentjay you are using the code from current master branch right?

vstoykov avatar Oct 14 '16 17:10 vstoykov