Free Canvas

167Download
Provide a canvas. Various cooperation is possible by shortcode and filter.
Description

Integrates Canvas into WordPress.

  • Provide canvas shortcode.
  • Provides a filter hook when saving the canvas.
  • It supports both mouse and touch.
  • It supports both the management screen and the public screen. The appearance of buttons and select boxes on the public screen depends on the CSS of the theme.

How to use the canvas

Sample of how to use the filter hook

  • Shortcode for canvas display
echo do_shortcode('[freecanvas height=500]');
  • shortcode
    Attribute : Default : Description
    width : 700 : Canvas width
    height : 700 : Canvas height
    name : The date and time string when the canvas was loaded : Unique name for this canvas
    form_name: null : The name of the form value you want to get
  • Filter hook & Function
/* Filter hook */
add_filter( 'free_canvas_save', 'canvas_save', 10, 5 );
/* Function for outputs a PNG image file */
function canvas_save( $image_data, $name, $form_value, $form_value2, $form_value3 ) {
    $wp_uploads = wp_upload_dir();
    $relation_path_true = strpos( $wp_uploads['baseurl'], '../' );
    if ( $relation_path_true > 0 ) {
        $upload_dir = wp_normalize_path( realpath( $wp_uploads['basedir'] ) );
    } else {
        $upload_dir = wp_normalize_path( $wp_uploads['basedir'] );
    }
    $filename = $upload_dir . '/' . $name . '.png';
    $image = imagecreatefromstring( $image_data );
    imagepng( $image, $filename );
}
  • Filter hook
    Variable : Description : From
    $image_data : PNG image data by Base64 : Value of Canvas
    $name : Unique name for this canvas : Value of Free Canvas
    $form_name : Form value obtained from form_name : Value of Form
Last Updated: 21 hours ago
Requires: 3.8.0
Compatible up to: 5.4
Release: 2020-02-04
Download: Version1.06