Skip to content
Roel Magdaleno edited this page Apr 22, 2020 · 2 revisions

The plugin has some useful filter hooks if you need to customize some default behavior:

wp_gp_pp_attachment_size

Description:

This filter hook allow you to change the original GIF attachment size to save in the database and extract the thumbnail image.

By default we use full size but you can choose any WordPress valid size like thumbnail, large, etc.

Default:

apply_filters( 'wp_gp_pp_attachment_size', 'full' );

Type: String

Example:

add_filter( 'wp_gp_pp_attachment_size', 'wp_gp_pp_change_attachment_size' );

function wp_gp_pp_change_attachment_size( $size ) {
   return 'thumbnail';
}

wp_gp_pp_video_types_and_commands

Description:

Get the video file extensions that will be used to convert the current GIF. Every file extension has its own command. That command belongs to our main dependency "ffmpeg".

By default we use the WebM and MP4 video formats, and every format has its own ffmpeg command.

Default:

$video_types = array(
   '.webm' => '-c vp9 -b:v 0 -crf 41',
   '.mp4'  => '-b:v 0 -crf 25 -f mp4 -vcodec libx264 -pix_fmt yuv420p',
);

apply_filters( 'wp_gp_pp_video_types_and_commands', $video_types );

Notice that the array key is the video format and the value is the ffmpeg command.

Type: Array

Example:

add_filter( 'wp_gp_pp_video_types_and_commands', 'wp_gp_pp_add_new_video_formats' );

function wp_gp_pp_add_new_video_formats( $video_formats ) {
   $video_formats['.avi'] = '<ffmpeg_command>';

   return $video_formats;
}

wp_gp_pp_video_mime_types

Description:

Get the video mime types to search the children posts that belongs to the current GIF with its attachment id.

By default we use the video/webm and video/mp4 mime types.

If you add another video format using the wp_gp_pp_video_types_and_commands filter you must implement this filter too.

Default:

$video_mime_types = array( 'video/webm', 'video/mp4' );
apply_filters( 'wp_gp_pp_video_mime_types', $video_mime_types );

Type: Array

Example:

add_filter( 'wp_gp_pp_video_mime_types', 'wp_gp_pp_add_new_mime_types' );

function wp_gp_pp_add_new_mime_types( $mime_types ) {
   $mime_types[] = 'video/mov';
   $mime_types[] = 'video/avi';

   return $mime_types;
}

wp_gp_pp_gif_css_classes

Description:

Change the CSS classes for the current GIF asset for GIF player method. This is recommended if you're trying to avoid Lazy Load for the GIF player.

Default:

$default = array( 'wp-gp-pp-gif' );
apply_filters( 'wp_gp_pp_gif_css_classes', $default );

Type: Array

Example:

add_filter( 'wp_gp_pp_gif_css_classes', 'wp_gp_pp_update_gif_css_classes' );

function wp_gp_pp_update_gif_css_classes( $css_classes ) {
   $css_classes[] = 'skip-lazy';

   return $css_classes;
}

wp_gp_pp_canvas_css_classes

Description:

Change the CSS classes for the current GIF asset for Canvas player method. This is recommended if you're trying to avoid Lazy Load for the GIF player.

Default:

$default = array( 'wp-gp-pp-gif-canvas-player' );
apply_filters( 'wp_gp_pp_canvas_css_classes', $default );

Type: Array

Example:

add_filter( 'wp_gp_pp_canvas_css_classes', 'wp_gp_pp_update_canvas_css_classes' );

function wp_gp_pp_update_canvas_css_classes( $css_classes ) {
   $css_classes[] = 'skip-lazy';

   return $css_classes;
}

wp_gp_pp_video_css_classes

Description:

Change the CSS classes for the current GIF asset for Video player method. This is recommended if you're trying to avoid Lazy Load for the GIF player.

Default:

$default = array( 'wp-gp-pp-video-player' );
apply_filters( 'wp_gp_pp_video_css_classes', $default );

Type: Array

Example:

add_filter( 'wp_gp_pp_video_css_classes', 'wp_gp_pp_update_video_css_classes' );

function wp_gp_pp_update_video_css_classes( $css_classes ) {
   $css_classes[] = 'skip-lazy';

   return $css_classes;
}