Jump to content

Custom Upload Names


adrian

Recommended Posts

@salles - unfortunately not, but I am curious how you are managing your image uploads with FTP - they won't be attached to a PW page, and so won't be accessible via the API. Please let us know your workflow - maybe there is something we can do to help.

Ivan - I think it should currently work almost like that by just using img-{$page->path} - if there is more than one image uploaded, it should start appending -1 etc, the same as PW does natively. Is it critical for you to a predefined number of characters in the number suffix like in your example? If so, let me know - it shouldn't be a hard thing to implement.

Link to comment
Share on other sites

@salles - unfortunately not, but I am curious how you are managing your image uploads with FTP - they won't be attached to a PW page, and so won't be accessible via the API. Please let us know your workflow - maybe there is something we can do to help.

Ah, nevermind. Didn't realize this :)

Just a note: I see the module supports capital letters in random strings but for some reason it only generates numbers and small letters...?  :mellow:  

Link to comment
Share on other sites

Ah, nevermind. Didn't realize this :)

Just a note: I see the module supports capital letters in random strings but for some reason it only generates numbers and small letters...?  :mellow:  

When you say the module supports capital letters in random strings I am assuming you were browsing the generateRandomString function? That was a bit of an oversight on my part. Even though that function generates the string to include capitals, the PW core does not allow capitals in filenames so they are converted automatically to lowercase. I should probably remove the capital letters from the $characters variable, but it really has no impact either way :)

Link to comment
Share on other sites

When you say the module supports capital letters in random strings I am assuming you were browsing the generateRandomString function? That was a bit of an oversight on my part. Even though that function generates the string to include capitals, the PW core does not allow capitals in filenames so they are converted automatically to lowercase. I should probably remove the capital letters from the $characters variable, but it really has no impact either way :)

Ah, gotcha :)

I wonder if this can be changed in some PW core file?!

Link to comment
Share on other sites

I wonder if this can be changed in some PW core file?!

You could hack the core to allow uppercase characters, but obviously this is not a good idea. Here is the function that handles this:

https://github.com/ryancramerdesign/ProcessWire/blob/a8024bb49785370aa2e3867bd683094663cfeabf/wire/core/Pagefiles.php#L258

A little reading on this issue:

https://processwire.com/talk/topic/7730-why-no-uppercase-or-special-characters-in-the-attached-files/

Link to comment
Share on other sites

I like my images having consistent names. But I probably will live without them. So it is up to you - please consider making this if you will have a little spare time for perfection )) Thank you for your module anyway. It should be on someone's list here.

Ivan - take a look at the latest version for me - let me know if that works how you expect. It should work exactly as you requested.

  • Like 1
Link to comment
Share on other sites

Dear Adrian! I just updated the module and finally, for the first time in 2 years was able to just through the pictures in there instead of manally renaming and moving them to the right folder. It was such a pleasure! You + PW just gifted me a moment of true happiness. I was delighted to show this to my companion working on Joomla! And equally proud of the community to say that this was just done in few days especially for my case. Can't find any dancing emoticon so putting this one :D.

My last challenge is to make them resize on upload.

  • Like 3
Link to comment
Share on other sites

Ivan - thanks for the feedback - glad it has made you so happy :)

Without getting too far down the road on the resize on upload topic in this thread, does the "Max Image Dimensions" setting on the Input tab do what you need? The description explains it as:

"Optionally enter the max width and/or height of uploaded images. If specified, images will be resized at upload time when they exceed either the max width or height. The resize is performed at upload time, and thus does not affect any images in the system, or images added via the API."

If you need some different behavior that you don't think already exists, perhaps you could post something in the Wishlist board.

  • Like 1
Link to comment
Share on other sites

Oh silly me) I've adjusted those settings a few times, but always thought they control maximum and minimum dimensions allowed. My only excuse is that "my can read not big white brotha letters much good" :-[  .

Probably by setting minimum and maximum to the same value I can achieve the exact size needed (not that it is needed too much since we scale images via API anyway). It would be cool to be able to define width:height ratio (like 4:3) though. And/or behaviour to scale images to that ratio defining scaling options like in imagefiled $options.

But all probably exeeds the scope of this topic. Thank you again, Adrian. I'll play with the newly discovered options and with your splendid module.

Link to comment
Share on other sites

  • 3 weeks later...

Good day, Adrian!

I believe I found a bug in the module. Once again it is probably encoding related (you're becoming true authority on that, like it or not :)). If "Rename on Save" option is checked and you have some images in RTE field, non-latin characters get screwed up on save. Like this:

post-2275-0-55756300-1417943165_thumb.pn

Most likely none-RTE fields and RTE fields without images are not affected.

Link to comment
Share on other sites

Hey Ivan - if I am becoming an expert on character encoding, then we should all be very scared - I still have no clue :)

But anyway, I have committed a fix which seems to work fine now in some limited tests. Can you please take a look and let me know.

  • Like 2
Link to comment
Share on other sites

  • 1 month later...

Please do, Adrian. I can't imagine living without your module anymore )

It's all fixed in the latest PW dev version. Martijn worked out one fix, but I think in the end Ryan solved the problem in a different way:

https://github.com/ryancramerdesign/ProcessWire/commit/5575ef62bb1695d98162bc3278b8d39bb66433b2#diff-995c5c9ce48d4bff459f52363c6e190eR401

  • Like 1
Link to comment
Share on other sites

I am using 2.5.14. And have no idea if it is the latest and greatest or not. Could you please suggest a way to keep track of dev branch updates. Sorry for offtopic here.

I am blindly going through the files on github dev branch and cannot even find those numbers there yet)))

Link to comment
Share on other sites

I am using 2.5.14. And have no idea if it is the latest and greatest or not. Could you please suggest a way to keep track of dev branch updates. Sorry for offtopic here.

I am blindly going through the files on github dev branch and cannot even find those numbers there yet)))

Ryan doesn't increase the point version number with every commit, so your best option is to subscribe to the dev RSS feed:

https://github.com/ryancramerdesign/ProcessWire/commits/dev.atom

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

Hey Ivan,

I just committed a fix, although in a hurry, so not tested, so please let me know if it works for you as expected.

Actually curious why you are using $page->title rather than $page->name - wouldn't it end up being the same thing?

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