360° Image developer reference

Filters and actions for changing 360° Image’s rotation, drag and frame settings.

Beka Rice Avatar

Written by

Last updated


360° Image has no settings for auto-rotation, drag or frame size. Developers can change them, and add markup around the rotating view, with the filters and actions below. Add them in a code snippets plugin or your child theme’s functions.php. For everyday setup, see Get started with 360° Image.

When you’d use this

  • Make the product turn on its own when the page loads.
  • Stop shoppers rotating the product by dragging.
  • Load smaller or larger images for each frame.
  • Add your own markup before or after the rotating view.

Filters

wc360_js_drag

Whether shoppers can drag to rotate. Default true. Swiping on touch screens stays on.

add_filter( 'wc360_js_drag', '__return_false' );

wc360_js_spin

Whether the product turns on its own when the page loads. Default false.

add_filter( 'wc360_js_spin', '__return_true' );

wc360_js_speed

How long each frame shows while the product turns on its own, in milliseconds. Default 80; a lower number turns faster.

add_filter( 'wc360_js_speed', function() {
	return 150;
} );

wc360_output_image_size

The WordPress image size used for each frame. Default large, or full on stores that had the rotation turned on before updating to 2.0.0.

add_filter( 'wc360_output_image_size', function() {
	return 'medium_large';
} );

wc360_image_output

Filters the rotating view’s HTML on the product page.

wc360_shortcode_image_output

Filters the rotating view’s HTML from the [wc360] shortcode.

Actions

wc360_before_image and wc360_after_image

Fire just before and after the rotating view on the product page.

wc360_shortcode_before_image and wc360_shortcode_after_image

Fire just before and after each rotating view the [wc360] shortcode outputs.

Filters removed in version 2.0.0

Version 2.0.0 replaced the rotation engine and removed wc360_js_responsive, wc360_js_framerate, wc360_js_playspeed and wc360_image_size. They no longer do anything. Use wc360_js_speed for the rotation speed and wc360_output_image_size for the frame size.

Keep learning