2

Firstly, I think the files should have unique names by default - nevertheless a problem came up yesterday in which one member's images were being displayed in place of another member's images because they had the same file names (it could possibly be a case sensitivity issue come to think of it).

I have a Matrix cell that contains a Safecracker file field. The purpose of this is to allow members to upload a series of photos, captions etc to an entry they are creating via the Safecracker form.

The problem I have is that it appears some of the images being uploaded have the same filenames. In my tests it appears that the files are appended with a number if there is a duplicate so I'm a little confused as to how this happened in the first place.

My 'solution' would be to prefix the filenames with the member ID. This should ensure that even if an image is overwritten it will be by the same member.

I found this extension https://github.com/rsanchez/safecracker_file_add_prefix which could do the trick but I am having trouble getting it to work in a Matrix - I think it may be a step too far.

So I'm looking for ideas and/or a solution!

Maybe the answer is to somehow convert the filenames to lowercase?

UPDATE: The issue was definitely caused by case insensitivity. The image pool.jpg was being displayed in place of Pool.jpg The server allows for the difference between upper and lowercase but it appears that ExpressionEngine or Matrix does not.

  • What did you end up doing to get this fixed? I'm kind of at a dead end. – Jim Pannell Aug 29 '13 at 12:32
1

This is probably way overkill for what you need (just posting it here as a solution for others), but Photo Frame can do this no problem. Photo Frame has a feature that allows you to create dynamic file names so the images never get overwritten. You can create filenames in any format you want. So you could do this (any many more formats):

{channel_id}-{entry_id}-{filename}.{extension}
{filename}-{random_string}.{extension}

It currently won't do the suggested format you mention, but I think that is a solid idea and will add it in the future.

Photo Frame works with Matrix too and you can pretty much control the experience to be whatever you need. Photo Frame is meant to replace the Safecracker File. There are FT settings to make it function in pretty much the same way.

https://objectivehtml.com/photo-frame

| improve this answer | |
  • That might be just the ticket. I've actually tracked this down to what I think is an oddity (bug?) with EE itself. – foamcow Jun 20 '13 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.