Jump to content
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By EyeDentify
      Hello There Guys.

      I am in the process of getting into making my first modules for PW and i had a question for you PHP and PW gurus in here.

      I was wondering how i could use an external library, lets say TwitterOAuth in my PW module.
      Link to library
      https://twitteroauth.com/

      Would the code below be correct or how would i go about this:
      <?PHP namespace ProcessWire; /* load the TwitterOAuth library from my Module folder */ require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; class EyeTwitter extends WireData,TwitterOAuth implements Module { /* vars */ protected $twConnection; /* extend parent TwitterOAuth contructor $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret); */ public function myTwitterConnection ($consumer_key, $consumer_secret, $access_token, $access_token_secret) { /* save the connection for use later */ $this->twConnection = TwitterOAuth::__construct($consumer_key, $consumer_secret, $access_token, $access_token_secret); } } ?> Am i on the right trail here or i am barking up the wrong tree?
      I don´t need a complete solution, i just wonder if i am including the external library the right way.
      If not, then give me a few hint´s and i will figure it out.

      Thanks a bunch.

      /EyeDentify
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
      As of 11 May 2019 ProcessWire versions earlier than 3.x are not supported
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend
       

×
×
  • Create New...