Keyword

Remove unix time stamp from k2 attachment filename

  • Andreas
  • Andreas's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago #133481 by Andreas
Hi,

When I add an attachment - which already exists in the joomla image folder - to a k2 article, the file gets a unix time stamp to the end of the file name. I would like to remove the time stamp because another system need the files to have their original file name. In which file is the code that add the time stamps?

Is there a reason for k2 to add the time stamp? Aren't the media manager already taking care of the uniqueness of the files? Or does k2 move the files from the folder where the user have uploaded the file, to a specific map for the current k2 article?

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #133482 by Lefteris
Hi. The timestamp is added in order to not delete the file with the same name that already exists. This cannot be changed. If you do not want this you need to ensure that the file you upload does not exist.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andreas
  • Andreas's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago - 9 years 11 months ago #133483 by Andreas
Hi, thanks for your answer!

The problem isn't when uploading the file, it's just when adding it as an attachment from the media manager. I have an unique item in the media manager (in this case a pdf) which I want to add to multiple k2 articles as an attachment. When adding it to the first article, the file keeps it's original name. But when adding it to another article the time stamp is added.

If I understand you correctly, and the time stamp would be removed, would it cause the file to be removed from all attachments from all articles? Is the attached file only identified from the time stamp, not from any article id's it's attached to? Because my clients would like to have the same file attached to multiple articles, and therefore use the same name on the downloadable pdf-file.

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #133484 by Lefteris
Unfortunately in K2 v2 when you select an existing file from server the file is copied in the attachments folder. That's why it gets renamed. For your case it might be better to add directly the attachment as a link in the item text or use an extra field link.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andreas
  • Andreas's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago #133485 by Andreas
Can you point me to where the time stamp is added, in which file?
I'm thinking I could possibly remove the time stamp from the file, and instead create a map with the time stamp as name. Then the same file could be copied to a time stamp generated map in the attachment folder.
Is there a disadvantage to making that change, do I have to change to much in K2's general structure?

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #133486 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Remove unix time stamp from k2 attachment filename
Actually I would not recommend this. I would follow Lefteri's solution beacuse of two reasons.

a) It can lead to unexpected results since a lot of files might need altering.
b) You will lose all your changes when you update. This means you need to patch your site every single time you update it. If you forget to backup you simply lose all your changes.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum