Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnail template tag saves thumbnail to MEDIA_URL using urlencoded path #1580

Closed
emenendez opened this issue Apr 4, 2016 · 1 comment
Closed
Labels

Comments

@emenendez
Copy link

When using the thumbnail template tag in a site which also uses the s3boto file-storage backend to store all media files in an S3-backed CDN, files containing any characters which are urlencoded result in broken thumbnail links. This seems to be because the thumbnail tag code saves the auto-generated thumbnail to S3 using a urlencoded path (https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/templatetags/mezzanine_tags.py#L400), but the s3boto backend does not expect this and does not un-encode it. Therefore, files are saved to S3 with with names such as "image-%23fff.png" instead of "image-#fff.png" and links to these files from the pages themselves are broken.

@AlexHill AlexHill added the bug label May 17, 2016
@AlexHill
Copy link
Collaborator

Looking over the code I think a simple change to the line you linked to should do the job. thumb_url is quoted because this is in a template tag, whose output is destined for an img element's href attribute – saving to S3 was probably added later, and the existing quoted path was used unchanged.

Can you try changing that line to

default_storage.save(unquote(thumb_url), File(f))

Let us know how you go.

jgroszko pushed a commit to jgroszko/mezzanine that referenced this issue Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants