Jump to content

Custom Upload Names


adrian

Recommended Posts

  • 1 month later...
4 hours ago, PWaddict said:

@adrian Checking "Rename on Save" and inserting the image link inside textarea field via "Insert Link" and then "Select File" and finally saving the page it doesn't update the link. It always lead to the previous filename. Can you please fix it?

Any chance you are inserting into a multi-language textarea field? If so, then it should be fixed in the latest version. If not, please let me know and I can investigate further.

 

Link to comment
Share on other sites

40 minutes ago, adrian said:

Any chance you are inserting into a multi-language textarea field? If so, then it should be fixed in the latest version. If not, please let me know and I can investigate further.

 

I was testing it in a NON multi-language textarea field.

Link to comment
Share on other sites

53 minutes ago, adrian said:

Any chance you are inserting into a multi-language textarea field? If so, then it should be fixed in the latest version.

I just tried it on a multi-language textarea field with the latest version (1.0.11) and it has the same problem.

5 minutes ago, adrian said:

Are you in a repeater or anything else unusual?

Nope

Link to comment
Share on other sites

If I understand correctly you've updated the part of the module that searches img tags inside textarea. The problem I'm having has nothing to do with img tags cause I do NOT  add the images inside textarea. I only add their LINKS via "Insert Link" and then "Select File".

  • Like 1
Link to comment
Share on other sites

12 hours ago, PWaddict said:

Yep although adding image links on a textarea field that belongs to another page it doesn't update them.

Good point. I am attaching a new version here for you to test. I don't have much time this morning to test it properly, but hopefully this will also handle that.

@simonsays - could also please test this version?

ProcessCustomUploadNames.zip

  • Like 2
Link to comment
Share on other sites

1 hour ago, adrian said:

I am attaching a new version here for you to test.

It's almost perfect. There is only 1 small issue:

Assuming that you have 2 tabs open in your browser. The 1st tab has the page where you renaming the image and the 2nd tab has the page with the textarea field where you inserting the image link. If I save the page on the 1st tab and then save the page on the 2nd tab without refreshing it then the old link will be saved and it will never gets updated again until I manually go and select the link via "Insert Link > Select File".

Link to comment
Share on other sites

4 minutes ago, PWaddict said:

It's almost perfect. There is only 1 small issue:

Assuming that you have 2 tabs open in your browser. The 1st tab has the page where you renaming the image and the 2nd tab has the page with the textarea field where you inserting the image link. If I save the page on the 1st tab and then save the page on the 2nd tab without refreshing it then the old link will be saved and it will never gets updated again until I manually go and select the link via "Insert Link > Select File".

Not really sure that could be dealt with without maintaining a database of filename changes and associated page ids and checking against them whenever a page is changed. If you have a simple approach I am not thinking of, I'd be happy to implement.

Link to comment
Share on other sites

3 hours ago, adrian said:

Not really sure that could be dealt with without maintaining a database of filename changes and associated page ids and checking against them whenever a page is changed. If you have a simple approach I am not thinking of, I'd be happy to implement.

I've temporarily disabled the rule just to test with PW core function on image linking and it doesn't update image links even if the image and the textarea are on the same page.

EDIT: Should I open issue on GitHub?

Link to comment
Share on other sites

41 minutes ago, PWaddict said:

On this version if the image and the textarea are on the same page the image links are not updated. On the 1.0.13 it works ok.

Strange - it seems to be working here. Is there something in your setup that differs from this?

jwZGw4sPhN.thumb.gif.f077a0949d38a3511639a00e8d2dd7ae.gif

Link to comment
Share on other sites

45 minutes ago, adrian said:

Strange - it seems to be working here. Is there something in your setup that differs from this?

No. I reinstalled the unreleased version again and it's working now but I've noticed that it doesn't always rename the filename when I save the page. On Filename format I'm using this $page->title-[Y-m-d_H-i-s] so I would know if image is renamed. Keep saving the page again and again and you'll notice the issue.

Link to comment
Share on other sites

1 minute ago, PWaddict said:

@adrian If I use this: [Y-m-d_H-i-s]-$page->title the filename ALWAYS renamed on save but if I use this $page->title-[Y-m-d_H-i-s] or this [Y-m-d_H-i-s] it doesn't.

Thanks for the debugging. That actually makes sense because I have a check to not rename files with "-n" extensions because PW's automatic adding of "-n" when there is already a file of the same name. I'll have to see if I can sort out a workaround for this, but I won't be able to look until tomorrow.

  • Like 1
Link to comment
Share on other sites

23 minutes ago, adrian said:

Thanks for the debugging. That actually makes sense because I have a check to not rename files with "-n" extensions because PW's automatic adding of "-n" when there is already a file of the same name. I'll have to see if I can sort out a workaround for this, but I won't be able to look until tomorrow.

Maybe you should allow the date format [Y-m-d_H-i-s]$file->mtime starting with underscore "_" instead of dash "-".

Link to comment
Share on other sites

On 11/25/2018 at 9:40 AM, PWaddict said:

Maybe you should allow the date format [Y-m-d_H-i-s]$file->mtime starting with underscore "_" instead of dash "-".

You should be able to specify any PHP date() format you want - if you want to replace those dashes with underscores you can. I think that should take care of the conflict with the "-n" suffix check.

Link to comment
Share on other sites

36 minutes ago, adrian said:

You should be able to specify any PHP date() format you want - if you want to replace those dashes with underscores you can. I think that should take care of the conflict with the "-n" suffix check.

A dot must be used between fields to work properly and yes about the php date underscores inside the brackets is the solution:

$page->title.[Y_m_d_H_i_s]

$page->title.$file->mtime

Don't forget to update the module with the proper version you posted above and also add the above examples in Rename Rules description. THANKS A LOT ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...