Skip to content

Instantly share code, notes, and snippets.

@prasetyop
Last active March 13, 2023 13:33
Show Gist options
  • Save prasetyop/f686a827bc0f4ca9089de7d115d3fa9c to your computer and use it in GitHub Desktop.
Save prasetyop/f686a827bc0f4ca9089de7d115d3fa9c to your computer and use it in GitHub Desktop.

Revisions

  1. prasetyop revised this gist Dec 22, 2017. No changes.
  2. prasetyop created this gist Dec 22, 2017.
    19 changes: 19 additions & 0 deletions admin.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    .acf-fc-popup .preview {
    position: absolute;
    right: 100%;
    margin-right: 0px;
    top: 0;
    background: #383c44;
    min-height: 100%;
    border-radius: 5px;
    align-content: center;
    display: grid;
    }

    .acf-fc-popup .preview .inner-preview {
    padding: 10px;
    }

    .acf-fc-popup .preview img {
    display: block;
    }
    19 changes: 19 additions & 0 deletions admin.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    jQuery(function($) {

    $(document).on('hover', '.acf-fc-popup li a', function() {

    var $this = $(this)
    var parent = $this.parents('.acf-fc-popup');
    var filename = $this.attr('data-layout');


    if (parent.find('.preview').length > 0) {
    parent.find('.preview').html('<div class="inner-preview"><img src="' + theme_var.upload + filename + '.jpg"/></div>')
    } else {
    parent.append('<div class="preview"><div class="inner-preview"><img src="' + theme_var.upload + filename + '.jpg"/></div></div>')
    }


    })

    })
    17 changes: 17 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // REGISTER CSS & JS
    add_action( 'admin_enqueue_scripts', 'acf_flexible_content_thumbnail' );
    function acf_flexible_content_thumbnail() {

    // REGISTER ADMIN.CSS
    wp_enqueue_style( 'css-theme-admin', get_template_directory_uri() . '/css/admin.css', false, 1.0 );

    // REGISTER ADMIN.JS
    wp_register_script( 'js-theme-admin', get_template_directory_uri() . '/js/admin.js', array('jquery'), 1.0, true );
    wp_localize_script( 'js-theme-admin', 'theme_var',
    array(
    'upload' => get_template_directory_uri().'/img/acf-thumbnail/',
    )
    );
    wp_enqueue_script( 'js-theme-admin');

    }