Coder Social home page Coder Social logo

sorl thumbnail about yawd-elfinder HOT 7 CLOSED

ppetrid avatar ppetrid commented on July 30, 2024
sorl thumbnail

from yawd-elfinder.

Comments (7)

 avatar commented on July 30, 2024

Hello, can you please describe me the problem and the steps to reproduce it? I'm willing to investigate this asap since we have also used sorl-thumbnail in the past and might also need it in the future.

from yawd-elfinder.

VladimirPal avatar VladimirPal commented on July 30, 2024

sorl thumbnail trying to find image in wrong path

    image = ElfinderField(optionset='image')
{% load thumbnail %}

{% thumbnail item.image "100x100" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

No such file or directory: u'/path_to_my_project/media/llffim_ZGljdG9waG9uZS1idWcucG5n'

from yawd-elfinder.

 avatar commented on July 30, 2024

since item.image is an ElfinderField, you should do:

{% thumbnail item.image.url "100x100" as im %} instead of {% thumbnail item.image "100x100" as im %}

Please tell me if this fixes it for you, for more info see this section of the yawd-elfinder documentation:
http://yawd-elfinder.readthedocs.org/en/latest/usage.html#django-templates

from yawd-elfinder.

VladimirPal avatar VladimirPal commented on July 30, 2024

Attempted access to '/media/images/my_image.png' denied.

from yawd-elfinder.

 avatar commented on July 30, 2024

sorry you are right, I see that sorl-thumbnail needs the absolute path instead of the url. I'll work on this as soon as possible, this fix must make it to the upcoming yawd-elfinder release this week.

from yawd-elfinder.

VladimirPal avatar VladimirPal commented on July 30, 2024

Great, I'll wait.

from yawd-elfinder.

 avatar commented on July 30, 2024

This turns out to by a problem originating from sorl-thumbnail path detection algorithm. Since in some cases (like when using the default yawd-elfinder optionsets) the image url is relative, sorl thinks the argument is a file path instead of a url. To solve this create a custom filter like this (tested with sorl-thumbnail 11.12):

@register.filter('fullurl')
def fullurl(value):
return 'http://localhost:8000%s' % value

and then in the template code

{% thumbnail item.image.url|fullurl "100x100" as im %}

Of course you could optimize the filter for dynamically retrieving the current domain (if you use the django sites framework for example), the above is mostly for demonstration purposes. I don't think we should change something in yawd-elfinder, especially since we support multiple drivers that could return either relative or absolute urls. Hopefully this workaround is sufficient for you, for more info please see also
this related issue http://stackoverflow.com/questions/7490684/using-static-images-with-sorl-thumbnail and the sorl-thumbnail documentation on how it resolves the image path http://sorl-thumbnail.readthedocs.org/en/latest/template.html#source

from yawd-elfinder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.