Support » Plugin: Image Regenerate & Select Crop » Modifying any input in general settings is causing page reload

  • Resolved platoche56

    (@platoche56)


    Hi,

    Many thanks for the plugin. Its is particularly useful to me as a way of preventing useless cropped images from being generated.

    I however encountered something slightly annoying today while I was trying to generate settings for specific kind of posts etc. Any input change is triggering an onchange event to save the change in setting. As I have large number of image sizes (this is intended), ticking each one of them one by one is very tedious. This is even worse for non-general settings as it requires two actions: choose the right category in the dropdown, change setting for each setting modified…

    In my opinion, it would be better he you would have to click on the ‘save changes’ button once your are done. Alternatively can you advise on how to add bulk settings for ‘global ignore’ programmatically using your plugin’s php functions.

    Can you advise please?

    Many thanks,

    A

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Iulia Cazan

    (@iulia-cazan)

    Hello,

    I understand. I will make some changes for the next release to submit the changed differently.

    For the global ignore feature, you can see examples here https://iuliacazan.ro/image-regenerate-select-crop-4-3/#feature3

    The example would show you how to generate only thumbnail + large image for the photo gallery and just thumbnail + medium for the rest of the images uploaded on my site. Let me know if this is close to what you need to accomplish.

    So, first, you would hook into the custom functionality like this:
    add_filter( 'sirsc_custom_upload_rule', 'gallery_custom_upload_rule', 99, 5 );

    Then you would write your own function to alter the settings used by the plugin, based on your own rules:

    
    if ( ! function_exists( 'gallery_custom_upload_rule' ) ) {
    	function gallery_custom_upload_rule( $settings, $id, $type, $parent_id, $parent_type ) {
    		if ( false === $is_gallery ) {
    			// This means the image is not matching the rule and we will generate a thumbnail + medium.
    			$settings['restrict_sizes_to_these_only'] = array( 'thumbnail', 'medium' );
    
    			// Make sure we tell the script that the biggest image is the medium size (so that the original file to be replaced).
    			$settings['force_original_to'] = 'medium';
    
    			// Tell the script to ignore all other image sizes except for the thumnail and medium.
    			$settings['complete_global_ignore'] = array_diff(
    				$settings['complete_global_ignore'],
    				array( 'thumbnail', 'medium' )
    			);
    		} else {
    			// This means the image is not matching the rule and we will generate a thumbnail + medium.
    			$settings['restrict_sizes_to_these_only'] = array( 'thumbnail', 'large' );
    
    			// Make sure we tell the script that the biggest image is the medium size (so that the original file to be replaced).
    			$settings['force_original_to'] = 'large';
    
    			// Tell the script to ignore all other image sizes except for the thumnail and medium.
    			$settings['complete_global_ignore'] = array_diff(
    				$settings['complete_global_ignore'],
    				array( 'thumbnail', 'large' )
    			);
    		}
    
    		return $settings;
    	}
    }
    

    However, depending on what you need to do, the settings can be changed differently.
    Let me know if this helps.

    Regards,
    Iulia

    v5.2 saves settings without reloading the page.

    Iulia, You can now remove the “save settings” buttons.

    Plugin Author Iulia Cazan

    (@iulia-cazan)

    Thank you Gal for checking. It is not doing any harm and it is still usable when something is hanging. What do you think?

    Up to you, of course. To me, the button implies a need to press it, which can be confusing, and it makes the UI more crowded, and the page is quite detailed already.

    Either way, this thread can be marked as resolved.

    Many thanks for the update. Quite helpful.

    I would personally have removed ajax calls entirely and switch it for a tab global save changes but the module is much easier to use now thanks to the changes you have made.

    Thanks for the documentation on the functions as well. Maybe would be worth adding this somewhere in the documentation or pushing it to a git repo and adding it here?

    Plugin Author Iulia Cazan

    (@iulia-cazan)

    I will add some more details about this in the plugin detail on my blog.
    @platoche56 & @galbaras, it would help a lot if you could rate/review my plugin. Thanks!

    Iulia

    @iulia-cazan will do as soon as I push it to a live site and start using it more. Trying to make as helpful a review as I can. I am still working on other bits at the moment so I did not use it properly or explored its functionalities entirely but you are on my to do list.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.