delete_sized_images() fails with custom upload_to
See original GitHub issueI have a custom upload_to
path:
def file_name(instance, path):
filename = os.path.basename(path)
sepFilename = os.path.splitext(filename)
newFilename = slugify(sepFilename[0]) + sepFilename[1]
year = str(instance.album.year)
album_slug = instance.album.slug
return '/'.join([year, album_slug, newFilename])
#...
class Image(BaseMedia):
file = VersatileImageField(upload_to=file_name)
#...
When I run delete_sized_images()
the files are not deleted. The problem is the custom path is both appended by get_sized_root_folder()
and prepended by sizer_regex
.
Example:
def delete_sized_images(self):
#...
print(self.get_sized_root_folder()) # __sized__/2015/sd/
print(self.sizer_regex.pattern) # 2015/sd/g0043229-(thumbnail|crop)-(\d+)x(\d+)(?:-\d+)?.JPG
#...
Thank you for your time.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Error in custom option file upload on magento 2.3.x
A few weeks ago some clients were uploading pdf files, and when they added to the cart, showed them an error the file...
Read more >[Magento 2.2.5 - 2.3.x] Upload fails in image uploader #16531
An error is shown: "File validation failed." No image is uploaded. I tried different kind of filetypes. In 2.2.4 and previous versions there...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @Mortal & @neic –
I thought I released this last month but I forgot to upload it to PyPI! This has been fixed in the 1.6 release which you can now install from PyPI:
Thanks for finding (and patching!) this bug! 😃
I’m not sure, is my bug related to this, but… I have custom
upload_to
path. But I’m not using subclassedSizedImage
. I have only several rendition key sets in settings like thisAnd pre-warmer in post_save signal like this
instance.RENDITION_KEYSET
matches key in settings.After I read #62 I suggest that my thumbnail images must contain
thumbnail
word in file name, but they doesn’t. And now I’m not sure, what should I fix. I have no control on thumbnail image file names. Only on original image. Should I subclassThumbnailImage
, redefine itfilename_key_regex
orfilename_key
? Or something else?