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 Robin S
      This module lets you add some custom menu items to the main admin menu, and you can set the dropdown links dynamically in a hook if needed.
      Sidenote: the module config uses some repeatable/sortable rows for the child link settings, similar to the ProFields Table interface. The data gets saved as JSON in a hidden textarea field. Might be interesting to other module developers?
      Custom Admin Menus
      Adds up to three custom menu items with optional dropdowns to the main admin menu.
      The menu items can link to admin pages, front-end pages, or pages on external websites.
      The links can be set to open in a new browser tab, and child links in the dropdown can be given an icon.
      Requires ProcessWire v3.0.178 or newer.
      Screenshots
      Example of menu items

      Module config for the menus

      Link list shown when parent menu item is not given a URL

      Advanced
      Setting child menu items dynamically
      If needed you can set the child menu items dynamically using a hook.
      Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $colours = $event->wire()->pages->findRaw('template=colour', ['title', 'url', 'page_icon']); $children = []; foreach($colours as $colour) { // Each child item should be an array with the following keys $children[] = [ 'icon' => $colour['page_icon'], 'label' => $colour['title'], 'url' => $colour['url'], 'newtab' => false, ]; } $event->return = $children; } }); Create multiple levels of flyout menus
      It's also possible to create multiple levels of flyout submenus using a hook.

      For each level a submenu can be defined in a "children" item. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $children = [ [ 'icon' => 'adjust', 'label' => 'One', 'url' => '/one/', 'newtab' => false, ], [ 'icon' => 'anchor', 'label' => 'Two', 'url' => '/two/', 'newtab' => false, 'children' => [ [ 'icon' => 'child', 'label' => 'Red', 'url' => '/red/', 'newtab' => false, ], [ 'icon' => 'bullhorn', 'label' => 'Green', 'url' => '/green/', 'newtab' => false, 'children' => [ [ 'icon' => 'wifi', 'label' => 'Small', 'url' => '/small/', 'newtab' => true, ], [ 'icon' => 'codepen', 'label' => 'Medium', 'url' => '/medium/', 'newtab' => false, ], [ 'icon' => 'cogs', 'label' => 'Large', 'url' => '/large/', 'newtab' => false, ], ] ], [ 'icon' => 'futbol-o', 'label' => 'Blue', 'url' => '/blue/', 'newtab' => true, ], ] ], [ 'icon' => 'hand-o-left', 'label' => 'Three', 'url' => '/three/', 'newtab' => false, ], ]; $event->return = $children; } }); Showing/hiding menus according to user role
      You can determine which menu items can be seen by a role by checking the user's role in the hook.
      For example, if a user has or lacks a role you could include different child menu items in the hook return value. Or if you want to conditionally hide a custom menu altogether you can set the return value to false. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); $user = $event->wire()->user; // For custom menu number 1... if($menu_number === 1) { // ...if user does not have some particular role... if(!$user->hasRole('foo')) { // ...do not show the menu $event->return = false; } } });  
      https://github.com/Toutouwai/CustomAdminMenus
      https://processwire.com/modules/custom-admin-menus/
    • By tcnet
      This module for ProcessWire sends a notification email for each failed login attempt. Similar modules exists already in the module directory of ProcessWire. However, this module is designed to notify, even if specified user doesn't exist.
      Settings
      The settings for this module are located in the menu Modules=>Configure=>LoginFailNotifier.
      Notification email
      Specifies the email address to which the notification emails should be sent.
        Email subject
      Specifies the subject line for the notification email.
        Post variables
      Specifies the $_POST variables to be included in the notification email. Each variable must be separated by a comma. For example: login_name,login_pass
        Server variables
      Specifies the $_SERVER variables to be included in the notification email. Each variable must be separated by a comma. For example: REMOTE_ADDR,HTTP_USER_AGENT
      Link to ProcessWire module directory:
      https://processwire.com/modules/login-fail-notifier/
      Link to github.com:
      https://github.com/techcnet/LoginFailNotifier
    • By Fokke
      ProcessWire 3.x markup module for rendering meta tags in HTML document head section. Note that this module is not a full-blown SEO solution, but rather a simple tool for rendering meta tags based on module configuration. Adding custom meta tags is also supported.
      Built-in meta tags
      The following meta tags are supported out-of-the-box:
      Document title consisting of page title and site name Character set Canonical Viewport Description Keywords Hreflang tags Open Graph og:title og:site_name og:type og:url og:description og:image og:image:width og:image:height Twitter meta tags twitter:card twitter:site twitter:creator twitter:title twitter:description twitter:image Facebook meta tags fb:app_id The full documentation with configurable options can be found here: https://github.com/Fokke-/MarkupMetadata
       
      Requirements:
      ProcessWire>=3.0.0 PHP >=7.1 Installation using Composer
      composer require fokke/markup-metadata Manual installation
      Download latest version from https://github.com/Fokke-/MarkupMetadata/archive/master.zip Extract module files to site/modules/MarkupMetadata directory.
    • By m.sieber
      ITRK-Service for ProcessWire
      Module for the automated transfer of imprint, data protection declaration and terms and conditions from IT-Recht Kanzlei to your ProcessWire installation
      What is ITRK Service for ProcessWire?
      ITRK-Service for ProcessWire is a free module for ProcessWire CMS. It provides an interface to the update service of IT-Recht Kanzlei, via which the legal texts of your online presence are automatically updated. In this way, the texts remain legally secure and warning-proof in the long term. Imprint, data protection declaration, revocation and general terms and conditions are currently supported.
      You can find our documentation (in german language) here: https://www.pupit.de/itrk-service-for-processwire/dokumentation/

      Download: https://www.pupit.de/itrk-service-for-processwire/
      Github: https://github.com/pupit-de/pwItrkServiceConnector
    • By LuisM
      Symprowire is a PHP MVC Framework based and built on Symfony using ProcessWire 3.x as DBAL and Service-Provider
      It acts as a Drop-In Replacement Module to handle the Request/Response outside the ProcessWire Admin. Even tough Symfony or any other mature MVC Framework could be intimidating at first, Symprowire tries to abstract Configuration and Symfony Internals away as much as possible to give you a quick start and lift the heavy work for you.
      The main Goal is to give an easy path to follow an MVC Approach during development with ProcessWire and open up the available eco-system.
      You can find the GitHub Repo and more Information here: https://github.com/Luis85/symprowire
      Documentation
      The Symprowire Wiki https://github.com/Luis85/symprowire/wiki How to create a simple Blog with Symprowire https://github.com/Luis85/symprowire/wiki/Symprowire-Blog-Tutorial Last Update
      16.07.2021 // RC 1 v0.6.0 centralized ProcessWire access trough out the Application by wrapping to a Service https://github.com/Luis85/symprowire/releases/tag/v0.6.0-rc-1 Requirements
      PHP ^7.4 Fresh ProcessWire ^3.0.181 with a Blank Profile Composer 2 (v1 should work, not recommended) The usual Symfony Requirements Features
      Twig Dependency Injection Monolog for Symprowire Support for .env YAML Configuration Symfony Console and Console Commands Symfony Webprofiler Full ProcessWire access inside your Controller and Services Webpack Encore support Caveats
      Symfony is no small Framework and will come with a price in terms of Memory Usage and added Overhead. To give you a taste I installed Tracy Debugger alongside to compare ProcessWire profiling with the included Symfony Webprofiler

      So in a fresh install Symprowire would atleast add another 2MB of Memory usage and around 40ms in response time, should be less in production due to the added overhead of the Webprofiler in dev env
       
×
×
  • Create New...