Giter VIP home page Giter VIP logo

Comments (7)

ricobl avatar ricobl commented on August 19, 2024

Hi @pythdasch, does it make sense to add this check?

What do you expect to happen when you pass None as a URL?

Your code should probably check this before calling the function or using the templatetag.

from django-thumbor.

ricobl avatar ricobl commented on August 19, 2024

I'm closing the issue ok? Feel free to comment.

from django-thumbor.

pythdasch avatar pythdasch commented on August 19, 2024

I agree with you but why not adding some exceptions ?

Thanks for the reply :)

from django-thumbor.

ricobl avatar ricobl commented on August 19, 2024

IMHO it's an unnecessary complexity, it's something that can be done outside the lib.

from django-thumbor.

pythdasch avatar pythdasch commented on August 19, 2024

By the way, I also have some changes that I made to fix the fact that sometimes we serve the media locally and to make it work in production I had to add :
def _prepend_media_url(url):
if url.startswith(settings.MEDIA_URL):
url = _remove_prefix(url, settings.MEDIA_URL)
url.lstrip('/')
return '%s/%s' % (conf.THUMBOR_MEDIA_URL, url)
return url

def _prepend_static_url(url):
if url.startswith(settings.STATIC_URL):
    url = _remove_prefix(url, settings.STATIC_URL)
    url.lstrip('/')
    return '%s/%s' % (conf.THUMBOR_STATIC_URL, url)
return url


def generate_url(image_url, **kwargs):
# if settings.DEBUG:
#     if not "http" in image_url:
#         dt = datetime.now()
#         image_url = "http://lorempixel.com/g/1000/1000/?%s"%(dt.microsecond)

image_url = _prepend_media_url(image_url)
image_url = _prepend_static_url(image_url)
image_url = _remove_schema(image_url)

kwargs = dict(conf.THUMBOR_ARGUMENTS, **kwargs)
thumbor_server = kwargs.pop(
    'thumbor_server', conf.THUMBOR_SERVER).rstrip('/')
encrypted_url = crypto.generate(image_url=image_url, **kwargs).strip('/')
return '%s/%s' % (thumbor_server, encrypted_url)

from django-thumbor.

ricobl avatar ricobl commented on August 19, 2024

Looks good @pythdasch, it could help others.

Would like to send a pull request with this code and tests?

from django-thumbor.

pythdasch avatar pythdasch commented on August 19, 2024

yes i could!
Le 17 mai 2016 19:31, "Enrico Batista da Luz" [email protected] a
Γ©crit :

Looks good @pythdasch https://github.com/pythdasch, it could help
others.

Would like to send a pull request with this code and tests?

β€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#7 (comment)

from django-thumbor.

Related Issues (11)

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.