Jump to content

Custom Upload Names


adrian

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!

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

  • 2 weeks later...
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?

Link to comment
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!

Link to comment
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 :)

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

Link to comment
Share on other sites

  • 2 months later...

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

  • 9 months later...

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

Link to comment
Share on other sites

  • 2 weeks later...

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.

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