BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
Ansel generates img:path img:url from timestamp not filename
#31 opened by obfuscode
Description
It looks like the img:path and img:url are generated using either the modified or uploaded timestamp instead of the filename or basename.
https://www.dropbox.com/s/hpuzuqqdwoni5do/ansel_bug.png?dl=0
I was able to track it down to the Service/AnselImages/ImagesTag.php setVariablesFromRecord
where it's using the $record
for most all variables except the path
and url
where it uses the raw $file
. I've modified it to the following (which isn't ideal as there's no getUrlSafeParam
on $record
).
https://www.dropbox.com/s/c8ici4mwbrqwucx/ansel-service-imagestag.png?dl=0
Replies
- obfuscode
Replied 6/19/2017 11:06 AM, Edited 11/10/2018 10:06 AM
Related to this issue, it looks like if you delete an entry that contains an Ansel -> Assets field, if you use the same image on another entry, that image is also deleted as Ansel calls
$this->sourceRouter->removeFile()
inService/AnselImages/DeleteRow.php
in thedelete()
method. Assets reuses images so it shouldn't delete the source image when removing the Ansel image.Commenting out that sourceRouter delete call seems to fix it deleting the image on the other entries.
- TJ Draper
Replied 6/21/2017 11:00 AM, Edited 11/10/2018 10:06 AM
Hi Jace, I cannot duplicate the issue where
path
andurl
are incorrect. The$file
variable is not raw, it's a class with information about the actual file so it should be right. I cannot fathom how it would not be right.Ansel will always delete manipulated images, but never original source images. This comes down to the distinction between the "Upload Directory" and the "Save Directory". As described in the documentation, and the instructions when setting up an Ansel field type:
> The upload directory is where raw source images (un-cropped and unmodified) are uploaded and stored. Images in this directory or uploaded to this directory will always be visible when selecting/uploading images to the field.
> The save directory is where Ansel will save and store the captured images. Images are named with the Ansel image ID and timestamp. Images in this directory are transient — they can come and go as the fields are updated and images are added and removed. The save directory is not meant to be a user-serviceable directory and is not seen by the user when adding/uploading images to the Ansel field.
> It is strongly recommended that you not use the same directory for both Upload and Save. Best practice is to create a separate directory for Ansel to save images to.
An Ansel field row instance expects to be the sole owner of the image it creates from the source image. As such, when the image changes, is re-cropped, or if its containing element/entry/whatever is deleted, the manipulated image (in the save directory) will be deleted.
- obfuscode
Replied 6/22/2017 7:08 AM, Edited 11/10/2018 10:06 AM
The issue only happens when there are multiple Ansel rows for different Channel Entries that reference the same
file_id
like so: https://www.dropbox.com/s/iuclu8kcy87370q/file_id.png?dl=0The
setVariablesFromRecord()
method in theansel/Service/AnselImages/ImagesTag.php
uses either$record
or$originalSource
for most all of the return vars exceptpath
url
description_field
credit_field
andlocation_field
. Shouldn't thepath
andurl
use the$record
object instead of the original$file
's data?Here's a better explanation (hopefully): https://www.dropbox.com/s/fxtg8unwf5it0cz/ansel-record-issue.png?dl=0
- TJ Draper
Replied 6/22/2017 9:06 AM, Edited 11/10/2018 10:06 AM
Ahh, well, I’ve discovered the issue then.
file_id
should be unique per row. There should never be duplicatefile_id
s. As I mentioned, a row expects to own the image it generates, per our prior conversations. In fact, I'd be willing to bet much money you were using Simple Cloner, which has duplicated rows, causing the samefile_id
to be used in multiple rows.file_id
refers to the image Ansel generates uniquely for that row (original_file_id
would be the source image you uploaded/selected for that row).So that also helps me understand images going missing in other places when you edit one somewhere else. Any time you delete an entry or a row, or even just modify the crop, the generated image for that row is deleted and a new one is generated.