adrian

Custom Upload Names

Recommended Posts

On 11/22/2018 at 2:37 AM, simonsays said:

Hello ūüôā

Sorry, I haven't forgotten - just had other priorities get in the way - I'll try to take a look soon.

Share this post


Link to post
Share on other sites

@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?

  • Like 1

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
11 minutes ago, PWaddict said:

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

Are you in a repeater or anything else unusual?

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
2 minutes ago, PWaddict said:

I only add their LINKS via "Insert Link" and then "Select File".

Oh sorry, I missed that distinction. I'll see what I can do about supporting that situation.

  • Like 1

Share this post


Link to post
Share on other sites

@PWaddict - it should now work in the latest version.

@simonsays - I think all your repeater issues should also now be fixed - sorry again for the huge delay on this.

  • Like 2

Share this post


Link to post
Share on other sites
13 minutes ago, adrian said:

it should now work in the latest version.

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

  • Like 1

Share this post


Link to post
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 1

Share this post


Link to post
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".

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
5 hours ago, adrian said:

ProcessCustomUploadNames.zip

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.

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

@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.

  • Like 1

Share this post


Link to post
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

Share this post


Link to post
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 "-".

Share this post


Link to post
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.

Share this post


Link to post
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 ūüôā

Share this post


Link to post
Share on other sites
1 minute ago, PWaddict said:

A dot must be used between fields to work properly

I use curly braces, like this:

{$page->title}-[Y_m_d_H_i_s]

 

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Anssi
      A simple module to enable easy navigation between the public and the admin side of the site. After installation a green bar will appear to the upper side of the screen, containing a few navigation elements and displaying the PW version number.
      Heavily inspired by @apeisa's great AdminBar (Thanks!). I needed a bit simpler tool for my projects and as a result, this was made. Available on GitHub .

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip