Support » Plugin: Simple Full Screen Background Image » Double Background to the homepage

  • Hi, on my homepage I have a button to switch between dark mode and white mode, but if I put a background in dark mode during white mode, everything else looks bad and becomes unwatchable, so I would like to change the background between one and the other, is it possible?
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Scott DeLuzio

    (@scottdeluzio)

    Unfortunately, this plugin lets you select only one image for the whole site. Are you using a plugin to switch between dark and white mode, or is this in your theme? If I can pinpoint what triggers the switch between dark and white mode I may be able to add this feature to the plugin.

    Thread Starter francoanim

    (@francoanim)

    Hi, thanks for the answer.
    The theme is custom and it’s all php and css, except for some essential plugins.
    Will I send you some files or access data?
    ps: the site is on a subdomain for testing.

    Plugin Author Scott DeLuzio

    (@scottdeluzio)

    It’s best to not send access to your site to strangers on the internet 🙂

    However, since it’s custom I would suggest that you use a conditional check for dark mode to switch the photo you use. Something like this should work:

    
    add_action( 'init', 'check_dark_mode' );
    function check_dark_mode() {
    	// note the $is_dark_mode variable is not a real variable that will return anything. You'll need to replace that with something that checks to see whether the site is in dark mode or not.
    	if ( $is_dark_mode ) {
    		// Remove the image the plugin displays.
    		remove_action( 'wp_footer', 'fsb_display_image' );
    		// Add your own dark mode image
    		add_action( 'wp_footer', 'fsb_display_dark_image' );
    		function fsb_display_dark_image() {
    			// Replace with your own dark mode image.
    			$image = 'https://yoursite.com/wp-content/uploads/your-image.png';
    			if( is_ssl() ) {
    				$image = str_replace( 'http://', 'https://', $image );
    			}
    			echo '<img src="' . esc_url( $image ) . '" id="fsb_image" alt=""/>';
    		}
    	}
    }
    

    In the plugin you’ll add the white mode image to the plugin’s settings. The code above will check if the site is in dark mode. If it is in dark mode, the code removes the action that displays the image from the plugin’s settings. Then it adds a new image using the code, which should be the image you want in dark mode.

    Give that a try and let me know if you need any other assistance with it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Double Background to the homepage’ is closed to new replies.