adrian

Custom Upload Names

Recommended Posts

@adrian

My settings: Enable fields -> images, Filename format: site-{$page->name}, Rename on save is ON.

If page->name = 'high-7' I lost one of file every save.

I fix it with: site-{$page->name}-### 

Now everything except lightning.pw works fine.

After submit new password on https://lightning.pw/login/change_password I get Safari can’t open the page “https://lightning.pw/login/change_password” because the server unexpectedly dropped the connection. This sometimes occurs when the server is busy. 

Thanks for your help!

Share this post


Link to post
Share on other sites

Thanks for the details. I think it must be a combination of the number in the page name and the "Rename on Save" setting. I am glad the custom ### option fixes it for you though :)

I still can't reproduce it here though, so just curious, what version of PW and CUN are you running? 

  • Like 1

Share this post


Link to post
Share on other sites
Hi @adrian, 
 
I have another strange issue. Some of images has new file name on the server but old name on the page.
 
Maybe you have an idea why it can be happens and how is possible to solve this?

Share this post


Link to post
Share on other sites
Hi @adrian, 
 
I have another strange issue. Some of images has new file name on the server but old name on the page.
 
Maybe you have an idea why it can be happens and how is possible to solve this?

Are you still using the "Rename on Save" option? That is likely the culprit, although I am not completely sure why. Obviously I would like to get that completely reliable, but in the meantime, do you actually need it? If you are setting the name of the image based on $page->name and you don't have anyway of changing the name of a page when the title is changed (the default behavior in PW), then I don't think there is much point to that setting in your case.

Just to confirm, is it the name of the image in the images field, or embedded into an RTE, or both?

Is it random or can you give me a way to reliably reproduce it?

Share this post


Link to post
Share on other sites
Dear Adrian, thank you for reply.
 
I use Rename on Save because I need it for API (for front-end photos uploading).
 
For this moment more than 100 pages affected, so I make copy from old backup and now copy each files back to actual server. (every page have 10-20 photos, so it's long story :)
 
But I realise moment, when all this happened.
 
I use this code to make changes for page field (I mean, field type page):
$chalets = wire('pages')->find("template=chalet, chalet_dining.id=13664, include=all");

foreach ($chalets as $page) {
			$page->of( false );
			$page->set("chalet_dining", 13668);
			wire( 'pages' )->save( $page );
			$page->of( true );
			echo $page->title;
}

After that all images on server get new names, but in database they still with previous file names.

And I wish you good luck with new Padloper!

Share this post


Link to post
Share on other sites

Sorry, I don't have much time right now to test your page field scenario, but in general you shouldn't need "Rename on Save" to make it work for API uploading. I just tested to confirm, and everything still works for me when adding an image like: 

$page->images->add("http://myserver.com/image.jpg");
$page->of(false);
$page->save();

What happens if you don't use "Rename on Save" at your end?

I'd really like to help you debug this when I have a few spare minutes, but it seems like I will need to replicate your page field setup - maybe you could create a site profile that I could test with?

Padloper is actually by @apeisa, but I am sure he'll appreciate your best wishes :)

Share this post


Link to post
Share on other sites

@adrian,

Let's leave this for the next week when my colleague, who take care about front-end come back from vacation.

And now I know that

@adrian

@apeisa

not mirrored nicknames or same person  :-[

Share this post


Link to post
Share on other sites

@adrian,

Let's leave this for the next week when my colleague, who take care about front-end come back from vacation.

Sounds good - please follow up with me when he is back - hopefully I can reproduce the issues you are having.

Share this post


Link to post
Share on other sites

Thanks for the report @ukyo - sorry that you and Ryan spent time debugging this.

I have committed a new version which appears to fix the problem for me.

Could you please test and let me know if it now works for you?

If anyone is interested in what the problem was, take a read of the Github issue.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for quick response. It look like ok now.

I tested it with default (3) ready to use fields.

  • Like 1

Share this post


Link to post
Share on other sites

Hi everyone, I just added multi-language support to this module.

I use it with alternate language file fields for translated versions of PDFs.

In my example, I have these two fields:

  • document_pdf
  • document_pdf_portugues

I am using this filename format setting: {$page->title}

Now when I upload, the PDF gets renamed to match the title of the page based on the language suffix of the field, eg.

a page with these multi-language titles:

My Document Title (default) | Meu Título do Documento (portugues)

results in pdfs named:

my-document-title.pdf |  meu-título-do-documento.pdf

Please note that I am still pretty new to this multi-language stuff, so let me know if you have any problems or have ideas for improvements.

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Hi,

I got an error

Error: Call to a member function get() on a non-object (line 346 of DIR_\site\assets\cache\FileCompiler\site\modules\ProcessCustomUploadNames\ProcessCustomUploadNames.module) 

After installing 'language support' it works...

Grtz 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, videokid said:

Hi,

I got an error


Error: Call to a member function get() on a non-object (line 346 of DIR_\site\assets\cache\FileCompiler\site\modules\ProcessCustomUploadNames\ProcessCustomUploadNames.module) 

After installing 'language support' it works...

Sorry about that - it should be fixed in the latest version.

  • Like 1

Share this post


Link to post
Share on other sites

No sorry needed :-)

After reading ' multi-language support', I had the feeling the problem was somewhere there, just wanted to notify you about this....

  • Like 1

Share this post


Link to post
Share on other sites
Just now, videokid said:

No sorry needed :-)

After reading ' multi-language support', I had the feeling the problem was somewhere there, just wanted to notify you about this....

It's a very important fix though - I wouldn't want to break anyone's non ML site if they upgraded to the latest version of this module, so very glad you reported this.

  • Like 2

Share this post


Link to post
Share on other sites

@JoZ3 - sorry about the trouble - what version of the module did you upgrade from? That curly brace was added for PHP7, and I tested on 5.6, but maybe there is a problem with 5.3.

I am sure I can write it a little differently to avoid the problem on 5.3, but just want to make sure that's definitely the issue.

Share this post


Link to post
Share on other sites
34 minutes ago, JoZ3 said:

Thanks mate, works fine!!!!!

Great - I have pushed that version to Github.

  • Like 2

Share this post


Link to post
Share on other sites

Hi @adrian can you add support for CROPPABLE IMAGE 3 module. If i add croppable image 3 field to custom upload names filter, when i want to upload file upload progress not finishing. Also i will put this problem link to Croppable Image 3 module post, because i don't know which module causing this error.

Ekran Resmi 2016-10-13 18.18.26.png

When i refresh page without save page, i can see these pictures names changed and uploaded.

Share this post


Link to post
Share on other sites

I'll take a look, but can you first post a screenshot of your settings for this module and also any dev console Network tab errors coming from the upload ajax request?

  • Like 1

Share this post


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

I'll take a look, but can you first post a screenshot of your settings for this module and also any dev console Network tab errors coming from the upload ajax request?

Sorry for early post before check console errors. Its look like error causing from Croppable Image 3 module. When i check ajax request there is an error:

Notice: Trying to get property of non-object in /website/site/modules/CroppableImage3/InputfieldCroppableImage3/InputfieldCroppableImage3.module on line 139

Ekran Resmi 2016-10-13 18.52.36.png

Ekran Resmi 2016-10-13 18.52.23.png

File: site/modules/CroppableImage3/InputfieldCroppableImage3/InputfieldCroppableImage3.module

$attr['data-image'] = $pagefile->getCrop($suffix)->url;

I think the module can't get data, because name is changed.

Here is custom upload names module filter settings :

Ekran Resmi 2016-10-13 18.50.35.png

  • Like 1

Share this post


Link to post
Share on other sites

Hi @ukyo - thanks for those details. Unfortunately I can't reproduce the problem here.

I put this Tracy dump call just before line 139 (as reported in the error):

bd($pagefile->getCrop($suffix)->url);

and it is correctly reporting the url to the cropped version of the file.

Perhaps there is a certain sequence of events that is required to trigger the error. Could you please detail exactly the steps involved starting from a new images field, including the crop settings you have configured for the field.

 

  • Like 1

Share this post


Link to post
Share on other sites

@adrian & @ukyo: I'm not aware of any upload processing done by CroppableImage3. It only extends the coreimage field in some points, but nothing in regard of uploading.

  • 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 Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.1.16
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By MoritzLost
      UPDATE: I have published a stable version of this module!
      Discussion thread:
      Github: https://github.com/MoritzLost/TextformatterPageTitleLinks
      ---
      Hello there,
      I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution 🙂
      It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright 😅
      You can download the module from Github:
      https://github.com/MoritzLost/TextformatterPageTitleLinks
      There's some more information in the readme as well.
      Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
    • By blad
      Hi guys!
      I just uploaded a module to explore files based on elFinder. By default it will show the "Files" folder.
      Screenshots:

      Video:
       
      To do:
       More options To fix:
       The function of rotating or scaling an image fails  Image editors V 1.01 (view issue)
      Fixed the bug working with the Multi-Language support ( translation of folders ). Fixed the name of elfinder.en  Github:
      https://github.com/LuisSantiago/ProcessElFinder/
      I hope you like it.
    • By BitPoet
      I'm really in love with FormBuilder, but the one thing missing to match all my end users' expectations were repeatable field groups. Think repeaters, in ProcessWire terms. Our primary application of PW is our corporate intranet, so "lines" of fields are quite common in the forms I build. We have all kinds of request forms where the information for a varying number of colleagues needs to be entered (from meal order to flight booking request) and where it is simply impractical to send a form for each, and I don't want to clutter my forms with multiple instances of fields that may only get used ten percent of the time.
      That's why I started to build FormBuilderMultiplier (link to GitHub).
      What it does:
      Adds an option to make a regular Fieldgroup repeatable Lets you limit the number of instances of a Fieldgroup on the form Adds an "Add row" button the form that adds another instance of the Fieldgroup's fields Adds a counter suffix at the end of every affected field's label Stores the entered values just like regular fields Makes the entered values available in preview and email notifications Supports most text based fields, textareas and selects (really, I haven't had enough time to test all the available choices yet) What it doesn't do (yet):
      Support saving to ProcessWire pages (i.e. real Repeaters) I haven't tested all the validation stuff, Date/Time inputs etc. yet, but since I'm utterly swamped with other stuff at work, I didn't want to wait until I have it polished. Any feedback is welcome. There might also be some issues with different output frameworks that I haven't encountered yet. The forms I work with mostly use UIKit.
      Status:
      Still alpha, so test well before using it in the field.
      Known issues:
      When rows are added, the form's iframe needs to be resized, which isn't completely clean yet.
      How it works:
      The Fieldgroup settings are added through regular hooks, as is the logic that adds the necessary field copies for processing the form and displaying previews.
      "Multiplied" field instances are suffixed with _NUM, where NUM is an incremental integer starting from 1. So if you have add two fields named "surname" and "givenname" to a fieldgroup and check the "multiply" checkbox, the form will initially have "surname_1" and "givenname_1" field (I'm still considering changing that to make the risk to shoot oneself into the foot by having a regular "surname_1" field somewhere else in the form less likely).
      When a "row" is added, the first row is cloned through JS and the counter in the fields' IDs, names and "for" attributes as well as the counter in the label are incremented before appending the copies to the Fieldset container in the form.
      To keep backend and frontend in sync, a hidden field named [name of the fieldset]__multiplier_rows is added to the form. Both the backend and the frontend script use this to store and retrieve the number of "rows".
      ToDo:
      Naturally, add the option to store the data in real repeaters when saving to pages. Do a lot of testing (and likely fixing). Make a few things (like the "Add row" button label etc.) configurable in field(set) context. Add a smooth API to retrieve the multiplied values as WireArrays. The mandatory moving screenshot: