PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 1.5.2
bBlocks – Essential Gutenberg Blocks & Patterns Collection v1.5.2
2.1.8 2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 All 108 releases
b-blocks / inc / gif.php

gif.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection 1.5.2, at inc/gif.php

51 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 class BBlocksGIF extends BBlocks{
3 public function __construct(){
4 add_action( 'init', [$this, 'register'] );
5 }
6
7 function register(){
8 $this::registerScripts( 'gif', array(
9 'attributes' => $this->attributes(),
10 'render_callback' => [$this, 'render']
11 ) );
12 }
13
14 function attributes(){
15 return array(
16 'align' => array( 'type' => 'string', 'default' => '' ),
17 'cId' => array( 'type' => 'string', 'default' => '' ),
18
19 'gif' => array( 'type' => 'object', 'default' => NULL ),
20 'gifAlign' => array( 'type' => 'string', 'default' => 'center' ),
21 'gifWidth' => array( 'type' => 'string', 'default' => '0px' )
22 );
23 }
24
25 function render( $attributes ){
26 extract( $attributes );
27
28 // Generate Styles
29 $gifStyle = new BBlocksStyleGenerator();
30 $gifStyle::addStyle( "#bBlocksGif-$cId .bBlocksGif", array(
31 'text-align' => $gifAlign
32 ) );
33 $gifStyle::addStyle( "#bBlocksGif-$cId .bBlocksGif figure", array(
34 'width' => '0px' === $gifWidth || '0%' === $gifWidth || '0em' === $gifWidth ? 'auto' : $gifWidth
35 ) );
36
37 ob_start(); ?>
38 <div class='wp-block-b-blocks-gif <?php echo 'align' . esc_attr( $align ); ?>' id='bBlocksGif-<?php echo esc_attr( $cId ); ?>'>
39 <style><?php echo wp_kses( $gifStyle::renderStyle(), array() ); ?></style>
40
41 <div class='bBlocksGif'>
42 <figure>
43 <?php echo isset( $gif ) && $gif ? "<img src='". esc_url( $gif['images']['original']['url'] ?? '' ) ."' alt='". esc_attr( $gif['title'] ?? '' ) ."' />" : ''; ?>
44 </figure>
45 </div>
46 </div>
47 <?php $gifStyle::$styles = array(); // Empty styles
48 return ob_get_clean();
49 }
50 }
51 new BBlocksGIF();