Title: Multisite and Default Settings?
Last modified: August 21, 2016

---

# Multisite and Default Settings?

 *  Resolved [RiseOfLex88](https://wordpress.org/support/users/riseoflex88/)
 * (@riseoflex88)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/multisite-and-default-settings/)
 * I’m planning to install this on a multisite network. However, by default all 
   thumbnail sizes are set to display.
 * Is there a way of hiding certain image sizes by default?
 * I’m assuming something could be done to automatically inject a site option with
   an array of the image sizes to show? Looking in the database I can see I get 
   the following:
 * `a:2:{s:16:"pte_hidden_sizes";a:7:{i:0;s:16:"tiny-thumb-image";i:1;s:11:"small-
   thumb";i:2;s:15:"full-page-image";i:3;s:14:"featured-image";i:4;s:10:"team-image";
   i:5;s:12:"driver-image";i:6;s:18:"driver-small-image";}s:12:"cache_buster";b:
   0;}`
 * I’ve managed to get the following together, but it’s not quite working…
 *     ```
       add_action('admin_init', 'confweb_set_pte_defaults' );
   
       function confweb_set_pte_defaults(){
   
       	if ( !is_plugin_active( 'post-thumbnail-editor/post-thumbnail-editor.php' ) ) return;
   
       	$pte_hidden_sizes = get_option('pte-site-options');
   
       	if(!empty($pte_hidden_sizes)) return;
   
       	$pte_hidden_sizes = array();
   
       	$image_sizes = get_intermediate_image_sizes();
       	foreach ($image_sizes as $size_name => $size_attrs):
       		$pte_hidden_sizes['pte_hidden_sizes'][] = $size_attrs;
       	endforeach;
   
       	$pte_hidden_sizes['cache_buster'] = '';
   
       	update_option( 'pte-site-options', serialize($pte_hidden_sizes) );
       }
       ```
   
 * At the moment I’m just trying to get all the sizes marked as hidden, then I can
   adjust as required to show the ones I’m after. However at this stage it’s not
   doing the job.
 * Any ideas?
 * [https://wordpress.org/plugins/post-thumbnail-editor/](https://wordpress.org/plugins/post-thumbnail-editor/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [sewpafly](https://wordpress.org/support/users/sewpafly/)
 * (@sewpafly)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/multisite-and-default-settings/#post-5147228)
 * It looks like you’re overwriting other settings other than just the hidden sizes.
   That could be causing a problem…
 * I would do something like this:
 *     ```
       $my_hidden_sizes = array( 'size1', 'size2' );
       $my_default_options = array( 'pte_hidden_sizes' => $my_hidden_sizes );
       $options = array_merge( get_option('pte_site_options'), $my_default_options );
       ```
   
 * Of course, the problem could be in the serialization. I handle the serialization
   through the wordpress backend, and don’t ever get that low level with it, so 
   that might be where the problem is.
 *  Thread Starter [RiseOfLex88](https://wordpress.org/support/users/riseoflex88/)
 * (@riseoflex88)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/multisite-and-default-settings/#post-5147279)
 * Ok, thanks sewpafly, The serialisation seemed to be the issue, looks like the
   update_option and get_option handle seriealisation anyway.
 * For anyone else to use / scrutinise, final code I’ve used looks like…
 *     ```
       /* *
          * This sets the default options for the thumbnail editor plugin. We're not planning on making the settings menu available to clients.
          * So we need to set the default values to hide the most obscure of image sizes.
          *
          * */
   
       add_action('admin_init', 'confweb_set_pte_defaults' );
   
       function confweb_set_pte_defaults(){
   
       	if ( !is_plugin_active( 'post-thumbnail-editor/post-thumbnail-editor.php' ) ) return;
   
       	$pte_hidden_sizes = get_option('pte-site-options');
   
       	// Look to see if this option actually needs to be set. Either because it's not been set before, or if it's been 2 days since we last checked.
       	$transient_check = get_transient('editable_thumbnails_expires');
       	if(empty($pte_hidden_sizes) || empty($transient_check)){
   
       		$pte_hidden_sizes = array();
   
       		// Dig out all currently registered sizes and automatically add them to be hidden
       		$image_sizes = get_intermediate_image_sizes();
       		foreach ($image_sizes as $size_name => $size_attrs):
       			$pte_hidden_sizes['pte_hidden_sizes'][] = $size_attrs;
       		endforeach;
   
       		$pte_hidden_sizes['cache_buster'] = '';
   
       		// Add a filter so that plugins can add image sizes to this list
       		$allowed_sizes = array();
       		$allowed_sizes = apply_filters( 'allow_image_size_from_post_thumbnail_editor', $allowed_sizes);
   
       		if(!empty($allowed_sizes)){
       			foreach($allowed_sizes as $size){
   
       				if(($key = array_search($size, $pte_hidden_sizes['pte_hidden_sizes'])) !== false) {
       	    			unset($pte_hidden_sizes['pte_hidden_sizes'][$key]);
       				}
   
       			}
       		}
   
       		update_option( 'pte-site-options', $pte_hidden_sizes );
   
       		set_transient( 'editable_thumbnails_expires', time(), HOUR_IN_SECONDS * 48 );
       	}
   
       	return;
       }
       ```
   
 * So that makes all image sizes hidden by default and refreshes the list every 
   48 hours. Then in our separate plugin it filters out the sizes I’d actually like
   to make editable.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Multisite and Default Settings?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/post-thumbnail-editor_afafac.svg)
 * [Post Thumbnail Editor](https://wordpress.org/plugins/post-thumbnail-editor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/post-thumbnail-editor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/post-thumbnail-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/post-thumbnail-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/post-thumbnail-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/post-thumbnail-editor/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [RiseOfLex88](https://wordpress.org/support/users/riseoflex88/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/multisite-and-default-settings/#post-5147279)
 * Status: resolved