Jump to content

Custom Upload Names


adrian

Recommended Posts

On 4/27/2021 at 5:43 AM, Kiwi Chris said:

This module works well, but with Lister Pro and inline editing within the Lister Pro table, even with the check box to update on save for this module, file names aren't renamed, although opening via a full edit and saving does work.

I suspect the issue might be the way Lister Pro works,  but if it's possible to get this module to work with inline editing mode in Lister Pro it would be handy.

Looks like the same issue I have with page repeater. It would be really cool to get this supported.

Link to comment
Share on other sites

Hi @adrian

With the 1.3.1 version when I try to save more than 1 repeater fields I'm getting this:

Look out Fatal Error: Uncaught Error: Call to a member function isTemp() on null in site/modules/ProcessCustomUploadNames/ProcessCustomUploadNames.module.php:414

#0 site/modules/ProcessCustomUploadNames/ProcessCustomUploadNames.module.php(225): ProcessCustomUploadNames->createNewFilename('/home/myusername...', 'myimage-16198119...', '', Object(Page), '287', Object(RepeaterPage))
#1 wire/core/Wire.php (397): ProcessCustomUploadNames->customRenameUploads(Object(HookEvent))
#2 wire/core/WireHooks.php (927): Wire->_callMethod('customRenameUpl...', Array)
#3 wire/core/Wire.php (465): WireHooks->runHooks(Object(Pages), 'saved', Array)
#4 wire/core/PagesEditor.php (746): Wire->__call('saved', Array)
#5 /home/myusername/publ (line 414 of site/modules/ProcessCustomUploadNames/ProcessCustomUploadNames.module.php)

 

Link to comment
Share on other sites

  • 2 weeks later...
6 hours ago, PWaddict said:

cause the 1.2.11 and 1.2.12 was generating duplicate images

Was this just in a repeater scenario?

I have been using the latest version extensively without any problems (and it solves lots of other issues), so I am assuming this is repeater specific?

I'll try to take a look shortly. Sorry, I haven't had much time for module maintenance lately.

Link to comment
Share on other sites

19 minutes ago, adrian said:

Was this just in a repeater scenario?

This was in a non-repeater. The duplicated images were generated on the 1.2.11 and 1.2.12 versions after uploading multiple images. I don't know if this happens on repeater too.

 

25 minutes ago, adrian said:

I have been using the latest version extensively without any problems (and it solves lots of other issues), so I am assuming this is repeater specific?

The fatal error I'm getting with the 1.3.1 version is when I try to save more than 1 repeater fields. I didn't have problems on non-repeaters.

 

27 minutes ago, adrian said:

I'll try to take a look shortly. Sorry, I haven't had much time for module maintenance lately.

No worries.

Link to comment
Share on other sites

@PWaddict - I have been trying to reproduce the issue with repeaters but can't so far. I have a feeling the duplicate image issue might not exist in 1.3.1 so I want to work on the repeater issue first and see if that fixes everything for you.

Can you please provide all the repeater field settings, the image field settings, and the CUN settings. There must be some combination I am not trying.

Link to comment
Share on other sites

38 minutes ago, adrian said:

Can you please provide all the repeater field settings, the image field settings, and the CUN settings. There must be some combination I am not trying.

Here are the settings for the repeater:

repeater_settings.thumb.png.12b1dc1b0943be59c2d9e3799218897b.png

 

Here are the settings (Details & Input) for the image field (Croppable Image 3):

image_settings_details.thumb.png.4438cc340ab44a5d320db54aaa2ea264.png

image_settings_input.thumb.png.559b285a8bd1c67eb478ff4c76a49e65.png

 

Here are the settings for Custom Upload Names:

ProcessCustomUploadNames_settings.thumb.png.485dfb2009b865e2767b40d0e015a635.png

 

I don't know if it matters but here are the settings for Auto Smush:

AutoSmush_settings.thumb.png.6e66447a3108300b8a7821ddbdaf7632.png

 

Make sure you have the 1.3.1 version installed of Custom Upload Names. The fatal error is happening if you try to edit already published more than 1 repeater pages and also when you try to create more than 1 new repeater pages.

  • Like 1
Link to comment
Share on other sites

On 4/26/2021 at 8:43 PM, Kiwi Chris said:

This module works well, but with Lister Pro and inline editing within the Lister Pro table, even with the check box to update on save for this module, file names aren't renamed, although opening via a full edit and saving does work.

I suspect the issue might be the way Lister Pro works,  but if it's possible to get this module to work with inline editing mode in Lister Pro it would be handy.

The reason is because ListerPro uses the saveField() when only field in the row is changed. If you edit two fields, then the rename will work because ListerPro then uses save() - you can see this starting on line 631 of the main ListerPro module file. It should be possible to make CUN work with this by adding a new hook to Pages::saveField.

I have this working but I think I need to test more for other possible side effects. If you'd like to help test, you can place:

            $this->addHookBefore('Pages::saveField', $this, 'customRenameUploads');

after this line: https://github.com/adrianbj/CustomUploadNames/blob/67b1d42aef4c23be92684420f0d282c0c4a9a8d4/ProcessCustomUploadNames.module.php#L101

Let me know how it goes for you.

  • Like 1
Link to comment
Share on other sites

I am having issues with a repeater as well. When I add an image it changes its name to "filename-upload-tmp", and not to the setting I have set up in the module. I updated to the latest version of the module, that didn't fix it. Seems like the issue is only for the images in the repeater.

Link to comment
Share on other sites

1 minute ago, Rostik RODE said:

I am having issues with a repeater as well. When I add an image it changes its name to "filename-upload-tmp", and not to the setting I have set up in the module. I updated to the latest version of the module, that didn't fix it. Seems like the issue is only for the images in the repeater.

Did it work fully with older versions of the module?

The problem is not actually repeater specific - the upload-tmp suffix is because the naming rule you defined relies on a field that isn't populated at the point when the image is uploaded. Obviously this happens in most situations with repeaters, but it will also happen with regular pages in that situation.

Can you share your settings like PWAddict did?

Link to comment
Share on other sites

Here are my settings

96730084_ScreenShot2021-05-18at9_30_38AM.thumb.png.1e04b8e4f4c971d8a5e0697629d9bc04.png

253366148_ScreenShot2021-05-18at9_31_07AM.thumb.png.68787d57f7c9749adf25c3e44b0736fb.png

571228510_ScreenShot2021-05-18at9_33_08AM.thumb.png.62974acd47329040c62df2f74f47af04.png

 

I havent tried an older version of the module on this specific site, but I used it on another sites with exact same setups, and didn't have any issues.

Thanks for your help!

Link to comment
Share on other sites

Thanks @Rostik RODE - I just tested those settings and can't reproduce the issue you are seeing. Any chance the title field for the page somehow isn't set when the image is uploaded? Usually this is unlikely because title is required and the first thing that is set when creating a new page, but that it really the only reason I can think of for the upload-tmp suffix being added - it's there so that the module knows that file needs to be renamed later, once that field value is available.

Link to comment
Share on other sites

Sorry @Rostik RODE - I am at a bit of a loss - still can't reproduce. Any chance you could share a login to the site so I can test?

Are there any other modules / hooks that might be interfering with image naming? or anything else you can think of?

Link to comment
Share on other sites

thanks for your help! 

its not that big of a deal, not worth spending too much time. i cant think of why it wouldn't work just for that one repeater. i have another repeater, where its a single image, so same image field but with a limit of 1 file in place,  and it works correctly. so perhaps it something to do with that 

 

Link to comment
Share on other sites

3 minutes ago, Rostik RODE said:

i have another repeater, where its a single image, so same image field but with a limit of 1 file in place,  and it works correctly. so perhaps it something to do with that 

I did my test with a multiple images field (max: 0) just like in your screenshot. It might be helpful if you could test on another template / repeater field setup with support for multiple images and see if you can narrow it down. If you've got a setup that doesn't work, I am sure others will come across this at some point as well.

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for creating a new measurement object from the sum or difference between two other objects. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.
      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      Screencasts
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      Exclusions
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
       
      https://github.com/Toutouwai/RepeaterEasySort
      https://processwire.com/modules/repeater-easy-sort/
×
×
  • Create New...