Skip to content

Instantly share code, notes, and snippets.

@emcniece
Created January 13, 2016 10:11
Show Gist options
  • Save emcniece/d885be8427c2282d3923 to your computer and use it in GitHub Desktop.
Save emcniece/d885be8427c2282d3923 to your computer and use it in GitHub Desktop.
Divi Theme Image and Gallery Modules with Thumbnail Size Selection
// Add this to the same directory as your functions.php
<?php
class CITTA_Builder_Module_Image extends ET_Builder_Module {
function init() {
$this->name = __( 'Custom Image', 'et_builder' );
$this->slug = 'et_pb_custom_image';
$this->whitelisted_fields = array(
'src',
'img_size',
'alt',
'title_text',
'show_in_lightbox',
'url',
'url_new_window',
'animation',
'sticky',
'align',
'admin_label',
'module_id',
'module_class',
'max_width',
'force_fullwidth',
'always_center_on_mobile',
);
$this->fields_defaults = array(
'img_size' => array( 'et-pb-portfolio-image-single' ),
'show_in_lightbox' => array( 'off' ),
'url_new_window' => array( 'off' ),
'animation' => array( 'left' ),
'sticky' => array( 'off' ),
'align' => array( 'left' ),
'force_fullwidth' => array( 'off' ),
'always_center_on_mobile' => array( 'on' ),
);
$this->advanced_options = array(
'border' => array(),
'custom_margin_padding' => array(
'use_padding' => false,
'css' => array(
'important' => 'all',
),
),
);
}
function get_fields() {
// List of animation options
$animation_options_list = array(
'left' => __( 'Left To Right', 'et_builder' ),
'right' => __( 'Right To Left', 'et_builder' ),
'top' => __( 'Top To Bottom', 'et_builder' ),
'bottom' => __( 'Bottom To Top', 'et_builder' ),
'fade_in' => __( 'Fade In', 'et_builder' ),
'off' => __( 'No Animation', 'et_builder' ),
);
$animation_option_name = sprintf( '%1$s-animation', $this->slug );
$default_animation_direction = ET_Global_Settings::get_value( $animation_option_name );
// If user modifies default animation option via Customizer, we'll need to change the order
if ( 'left' !== $default_animation_direction && array_key_exists( $default_animation_direction, $animation_options_list ) ) {
// The options, sans user's preferred direction
$animation_options_wo_default = $animation_options_list;
unset( $animation_options_wo_default[ $default_animation_direction ] );
// All animation options
$animation_options = array_merge(
array( $default_animation_direction => $animation_options_list[$default_animation_direction] ),
$animation_options_wo_default
);
} else {
// Simply copy the animation options
$animation_options = $animation_options_list;
}
$fields = array(
'src' => array(
'label' => __( 'Image URL', 'et_builder' ),
'type' => 'upload',
'upload_button_text' => __( 'Upload an image', 'et_builder' ),
'choose_text' => __( 'Choose an Image', 'et_builder' ),
'update_text' => __( 'Set As Image', 'et_builder' ),
'description' => __( 'Upload your desired image, or type in the URL to the image you would like to display.', 'et_builder' ),
),
'img_size' => array(
'label' => __( 'Image Size', 'et_builder' ),
'type' => 'select',
'options' => get_image_sizes(),
'description' => __( 'Select a resized image format', 'et_builder' ),
),
'alt' => array(
'label' => __( 'Image Alternative Text', 'et_builder' ),
'type' => 'text',
'description' => __( 'This defines the HTML ALT text. A short description of your image can be placed here.', 'et_builder' ),
),
'title_text' => array(
'label' => __( 'Image Title Text', 'et_builder' ),
'type' => 'text',
'description' => __( 'This defines the HTML Title text.', 'et_builder' ),
),
'show_in_lightbox' => array(
'label' => __( 'Open in Lightbox', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'off' => __( "No", 'et_builder' ),
'on' => __( 'Yes', 'et_builder' ),
),
'affects' => array(
'#et_pb_url',
'#et_pb_url_new_window',
),
'description' => __( 'Here you can choose whether or not the image should open in Lightbox. Note: if you select to open the image in Lightbox, url options below will be ignored.', 'et_builder' ),
),
'url' => array(
'label' => __( 'Link URL', 'et_builder' ),
'type' => 'text',
'depends_show_if' => 'off',
'description' => __( 'If you would like your image to be a link, input your destination URL here. No link will be created if this field is left blank.', 'et_builder' ),
),
'url_new_window' => array(
'label' => __( 'Url Opens', 'et_builder' ),
'type' => 'select',
'options' => array(
'off' => __( 'In The Same Window', 'et_builder' ),
'on' => __( 'In The New Tab', 'et_builder' ),
),
'depends_show_if' => 'off',
'description' => __( 'Here you can choose whether or not your link opens in a new window', 'et_builder' ),
),
'animation' => array(
'label' => __( 'Animation', 'et_builder' ),
'type' => 'select',
'options' => $animation_options,
'description' => __( 'This controls the direction of the lazy-loading animation.', 'et_builder' ),
),
'sticky' => array(
'label' => __( 'Remove Space Below The Image', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'off' => __( 'No', 'et_builder' ),
'on' => __( 'Yes', 'et_builder' ),
),
'description' => __( 'Here you can choose whether or not the image should have a space below it.', 'et_builder' ),
),
'align' => array(
'label' => __( 'Image Alignment', 'et_builder' ),
'type' => 'select',
'options' => array(
'left' => __( 'Left', 'et_builder' ),
'center' => __( 'Center', 'et_builder' ),
'right' => __( 'Right', 'et_builder' ),
),
'description' => __( 'Here you can choose the image alignment.', 'et_builder' ),
),
'admin_label' => array(
'label' => __( 'Admin Label', 'et_builder' ),
'type' => 'text',
'description' => __( 'This will change the label of the module in the builder for easy identification.', 'et_builder' ),
),
'module_id' => array(
'label' => __( 'CSS ID', 'et_builder' ),
'type' => 'text',
'description' => __( 'Enter an optional CSS ID to be used for this module. An ID can be used to create custom CSS styling, or to create links to particular sections of your page.', 'et_builder' ),
),
'module_class' => array(
'label' => __( 'CSS Class', 'et_builder' ),
'type' => 'text',
'description' => __( 'Enter optional CSS classes to be used for this module. A CSS class can be used to create custom CSS styling. You can add multiple classes, separated with a space.', 'et_builder' ),
),
'max_width' => array(
'label' => __( 'Image Max Width', 'et_builder' ),
'type' => 'text',
'tab_slug' => 'advanced',
),
'force_fullwidth' => array(
'label' => __( 'Force Fullwidth', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'off' => __( "No", 'et_builder' ),
'on' => __( 'Yes', 'et_builder' ),
),
'tab_slug' => 'advanced',
),
'always_center_on_mobile' => array(
'label' => __( 'Always Center Image On Mobile', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'on' => __( 'Yes', 'et_builder' ),
'off' => __( "No", 'et_builder' ),
),
'tab_slug' => 'advanced',
),
);
return $fields;
}
function shortcode_callback( $atts, $content = null, $function_name ) {
$module_id = $this->shortcode_atts['module_id'];
$module_class = $this->shortcode_atts['module_class'];
$src = $this->shortcode_atts['src'];
$img_size = $this->shortcode_atts['img_size'];
$alt = $this->shortcode_atts['alt'];
$title_text = $this->shortcode_atts['title_text'];
$animation = $this->shortcode_atts['animation'];
$url = $this->shortcode_atts['url'];
$url_new_window = $this->shortcode_atts['url_new_window'];
$show_in_lightbox = $this->shortcode_atts['show_in_lightbox'];
$sticky = $this->shortcode_atts['sticky'];
$align = $this->shortcode_atts['align'];
$max_width = $this->shortcode_atts['max_width'];
$force_fullwidth = $this->shortcode_atts['force_fullwidth'];
$always_center_on_mobile = $this->shortcode_atts['always_center_on_mobile'];
$module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name );
if( ('' !== $img_size) && ($img_id = get_image_id($src) ) ){
$img_obj = wp_get_attachment_image_src( $img_id, $img_size );
if( $img_obj[0]){
$src = $img_obj[0];
}
}
if ( 'on' === $always_center_on_mobile ) {
$module_class .= ' et_always_center_on_mobile';
}
if ( '' !== $max_width ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%%',
'declaration' => sprintf(
'max-width: %1$s;',
esc_html( et_builder_process_range_value( $max_width ) )
),
) );
}
if ( 'on' === $force_fullwidth ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%% img',
'declaration' => 'width: 100%;',
) );
}
if ( $this->fields_defaults['align'][0] !== $align ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%%',
'declaration' => sprintf(
'text-align: %1$s;',
esc_html( $align )
),
) );
}
$output = sprintf(
'<img src="%1$s" alt="%2$s"%3$s />',
esc_attr( $src ),
esc_attr( $alt ),
( '' !== $title_text ? sprintf( ' title="%1$s"', esc_attr( $title_text ) ) : '' )
);
if ( 'on' === $show_in_lightbox ) {
$output = sprintf( '<a href="%1$s" class="et_pb_lightbox_image" title="%3$s">%2$s</a>',
esc_url( $src ),
$output,
esc_attr( $alt )
);
} else if ( '' !== $url ) {
$output = sprintf( '<a href="%1$s"%3$s>%2$s</a>',
esc_url( $url ),
$output,
( 'on' === $url_new_window ? ' target="_blank"' : '' )
);
}
$animation = '' === $animation ? ET_Global_Settings::get_value( 'et_pb_image-animation' ) : $animation;
$output = sprintf(
'<div%5$s class="et_pb_module et-waypoint et_pb_image%2$s%3$s%4$s">
%1$s
</div>',
$output,
esc_attr( " et_pb_animation_{$animation}" ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( ltrim( $module_class ) ) ) : '' ),
( 'on' === $sticky ? esc_attr( ' et_pb_image_sticky' ) : '' ),
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' )
);
return $output;
}
}
new CITTA_Builder_Module_Image;
// retrieves the attachment ID from the file URL
function get_image_id($image_url) {
global $wpdb;
$attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
return $attachment[0];
}
/*============================================
= Citta Custom Gallery =
============================================*/
class CITTA_Builder_Module_Gallery extends ET_Builder_Module {
function init() {
$this->name = __( 'Custom Gallery', 'et_builder' );
$this->slug = 'et_pb_custom_gallery';
$this->whitelisted_fields = array(
'src',
'gallery_ids',
'gallery_orderby',
'fullwidth',
'thumb_size',
'posts_number',
'show_title_and_caption',
'show_pagination',
'background_layout',
'auto',
'auto_speed',
'admin_label',
'module_id',
'module_class',
'zoom_icon_color',
'hover_overlay_color',
'hover_icon',
);
$this->fields_defaults = array(
'fullwidth' => array( 'off' ),
'thumb_size' => array( 'citta-gal-large'),
'posts_number' => array( 4, 'add_default_setting' ),
'show_title_and_caption' => array( 'on' ),
'show_pagination' => array( 'on' ),
'background_layout' => array( 'light' ),
'auto' => array( 'off' ),
'auto_speed' => array( '7000' ),
);
$this->main_css_element = '%%order_class%%.et_pb_gallery';
$this->advanced_options = array(
'fonts' => array(
'caption' => array(
'label' => __( 'Caption', 'et_builder' ),
'use_all_caps' => true,
'css' => array(
'main' => "{$this->main_css_element} .mfp-title",
),
'line_height' => array(
'range_settings' => array(
'min' => '1',
'max' => '100',
'step' => '1',
),
),
),
'title' => array(
'label' => __( 'Title', 'et_builder' ),
'css' => array(
'main' => "{$this->main_css_element} .et_pb_gallery_title",
),
),
),
'border' => array(),
);
$this->custom_css_options = array(
'gallery_item' => array(
'label' => __( 'Gallery Item', 'et_builder' ),
'selector' => '.et_pb_gallery_item',
),
'overlay' => array(
'label' => __( 'Overlay', 'et_builder' ),
'selector' => '.et_overlay',
),
'overlay_icon' => array(
'label' => __( 'Overlay Icon', 'et_builder' ),
'selector' => '.et_overlay:before',
),
'gallery_item_title' => array(
'label' => __( 'Gallery Item Title', 'et_builder' ),
'selector' => '.et_pb_gallery_title',
),
);
}
function get_fields() {
$fields = array(
'src' => array(
'label' => __( 'Gallery Images', 'et_builder' ),
'renderer' => 'et_builder_get_gallery_settings',
),
'gallery_ids' => array(
'type' => 'hidden',
'class' => array( 'et-pb-gallery-ids-field' ),
),
'gallery_orderby' => array(
'label' => __( 'Gallery Images', 'et_builder' ),
'type' => 'hidden',
'class' => array( 'et-pb-gallery-ids-field' ),
),
'fullwidth' => array(
'label' => __( 'Layout', 'et_builder' ),
'type' => 'select',
'options' => array(
'on' => __( 'Slider', 'et_builder' ),
'off' => __( 'Grid', 'et_builder' ),
),
'description' => __( 'Toggle between the various blog layout types.', 'et_builder' ),
'affects' => array(
'#et_pb_zoom_icon_color',
'#et_pb_caption_font',
'#et_pb_caption_font_color',
'#et_pb_caption_font_size',
'#et_pb_hover_overlay_color',
'#et_pb_auto',
),
),
'thumb_size' => array(
'label' => __( 'Thumbnail Size', 'et_builder' ),
'type' => 'select',
'options' => get_image_sizes(),
'description' => __( 'Only applies to initially visible images', 'et_builder' ),
),
'posts_number' => array(
'label' => __( 'Images Number', 'et_builder' ),
'type' => 'text',
'description' => __( 'Define the number of images that should be displayed per page.', 'et_builder' ),
),
'show_title_and_caption' => array(
'label' => __( 'Show Title and Caption', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'on' => __( 'Yes', 'et_builder' ),
'off' => __( 'No', 'et_builder' ),
),
'description' => __( 'Here you can choose whether to show the images title and caption, if the image has them.', 'et_builder' ),
),
'show_pagination' => array(
'label' => __( 'Show Pagination', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'on' => __( 'Yes', 'et_builder' ),
'off' => __( 'No', 'et_builder' ),
),
'description' => __( 'Enable or disable pagination for this feed.', 'et_builder' ),
),
'background_layout' => array(
'label' => __( 'Text Color', 'et_builder' ),
'type' => 'select',
'options' => array(
'light' => __( 'Dark', 'et_builder' ),
'dark' => __( 'Light', 'et_builder' ),
),
'description' => __( 'Here you can choose whether your text should be light or dark. If you are working with a dark background, then your text should be light. If your background is light, then your text should be set to dark.', 'et_builder' ),
),
'auto' => array(
'label' => __( 'Automatic Animation', 'et_builder' ),
'type' => 'yes_no_button',
'options' => array(
'off' => __( 'Off', 'et_builder' ),
'on' => __( 'On', 'et_builder' ),
),
'affects' => array(
'#et_pb_auto_speed',
),
'depends_show_if' => 'on',
'description' => __( 'If you would like the slider to slide automatically, without the visitor having to click the next button, enable this option and then adjust the rotation speed below if desired.', 'et_builder' ),
),
'auto_speed' => array(
'label' => __( 'Automatic Animation Speed (in ms)', 'et_builder' ),
'type' => 'text',
'depends_default' => true,
'description' => __( "Here you can designate how fast the slider fades between each slide, if 'Automatic Animation' option is enabled above. The higher the number the longer the pause between each rotation.", 'et_builder' ),
),
'admin_label' => array(
'label' => __( 'Admin Label', 'et_builder' ),
'type' => 'text',
'description' => __( 'This will change the label of the module in the builder for easy identification.', 'et_builder' ),
),
'module_id' => array(
'label' => __( 'CSS ID', 'et_builder' ),
'type' => 'text',
'description' => __( 'Enter an optional CSS ID to be used for this module. An ID can be used to create custom CSS styling, or to create links to particular sections of your page.', 'et_builder' ),
),
'module_class' => array(
'label' => __( 'CSS Class', 'et_builder' ),
'type' => 'text',
'description' => __( 'Enter optional CSS classes to be used for this module. A CSS class can be used to create custom CSS styling. You can add multiple classes, separated with a space.', 'et_builder' ),
),
'zoom_icon_color' => array(
'label' => __( 'Zoom Icon Color', 'et_builder' ),
'type' => 'color',
'custom_color' => true,
'depends_show_if' => 'off',
'tab_slug' => 'advanced',
),
'hover_overlay_color' => array(
'label' => __( 'Hover Overlay Color', 'et_builder' ),
'type' => 'color-alpha',
'custom_color' => true,
'depends_show_if' => 'off',
'tab_slug' => 'advanced',
),
'hover_icon' => array(
'label' => __( 'Hover Icon Picker', 'et_builder' ),
'type' => 'text',
'class' => array( 'et-pb-font-icon' ),
'renderer' => 'et_pb_get_font_icon_list',
'renderer_with_field' => true,
'tab_slug' => 'advanced',
),
);
return $fields;
}
function shortcode_callback( $atts, $content = null, $function_name ) {
$module_id = $this->shortcode_atts['module_id'];
$module_class = $this->shortcode_atts['module_class'];
$gallery_ids = $this->shortcode_atts['gallery_ids'];
$fullwidth = $this->shortcode_atts['fullwidth'];
$thumb_size = $this->shortcode_atts['thumb_size'];
$show_title_and_caption = $this->shortcode_atts['show_title_and_caption'];
$background_layout = $this->shortcode_atts['background_layout'];
$posts_number = $this->shortcode_atts['posts_number'];
$show_pagination = $this->shortcode_atts['show_pagination'];
$gallery_orderby = $this->shortcode_atts['gallery_orderby'];
$zoom_icon_color = $this->shortcode_atts['zoom_icon_color'];
$hover_overlay_color = $this->shortcode_atts['hover_overlay_color'];
$hover_icon = $this->shortcode_atts['hover_icon'];
$auto = $this->shortcode_atts['auto'];
$auto_speed = $this->shortcode_atts['auto_speed'];
$module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name );
if ( '' !== $zoom_icon_color ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%% .et_overlay:before',
'declaration' => sprintf(
'color: %1$s !important;',
esc_html( $zoom_icon_color )
),
) );
}
if ( '' !== $hover_overlay_color ) {
ET_Builder_Element::set_style( $function_name, array(
'selector' => '%%order_class%% .et_overlay',
'declaration' => sprintf(
'background-color: %1$s;',
esc_html( $hover_overlay_color )
),
) );
}
$attachments = array();
if ( ! empty( $gallery_ids ) ) {
$attachments_args = array(
'include' => $gallery_ids,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'post__in',
);
if ( 'rand' === $gallery_orderby ) {
$attachments_args['orderby'] = 'rand';
}
$_attachments = get_posts( $attachments_args );
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
}
if ( empty($attachments) )
return '';
wp_enqueue_script( 'hashchange' );
$fullwidth_class = 'on' === $fullwidth ? ' et_pb_slider et_pb_gallery_fullwidth' : ' et_pb_gallery_grid';
$background_class = " et_pb_bg_layout_{$background_layout}";
$module_class .= 'on' === $auto && 'on' === $fullwidth ? ' et_slider_auto et_slider_speed_' . esc_attr( $auto_speed ) : '';
$output = sprintf(
'<div%1$s class="et_pb_module et_pb_gallery%2$s%3$s%4$s clearfix">
<div class="et_pb_gallery_items et_post_gallery" data-per_page="%5$d">',
( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
( '' !== $module_class ? sprintf( ' %1$s', esc_attr( ltrim( $module_class ) ) ) : '' ),
esc_attr( $fullwidth_class ),
esc_attr( $background_class ),
esc_attr( $posts_number )
);
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$width = 'on' === $fullwidth ? 1080 : 400;
$width = (int) apply_filters( 'et_pb_gallery_image_width', $width );
$height = 'on' === $fullwidth ? 9999 : 284;
$height = (int) apply_filters( 'et_pb_gallery_image_height', $height );
list($full_src, $full_width, $full_height) = wp_get_attachment_image_src( $id, 'full' );
list($thumb_src, $thumb_width, $thumb_height) = wp_get_attachment_image_src( $id, array( $width, $height ) );
if('' !== $thumb_size){
$thumb_obj = wp_get_attachment_image_src( $id, $thumb_size );
$thumb_src = $thumb_obj[0];
}
$data_icon = '' !== $hover_icon
? sprintf(
' data-icon="%1$s"',
esc_attr( et_pb_process_font_icon( $hover_icon ) )
)
: '';
$image_output = sprintf(
'<a href="%1$s" title="%2$s">
<img src="%3$s" alt="%2$s" data-excerpt="%6$s" data-alt="%7$s" data-title="%8$s" data-caption="%9$s" />
<span class="et_overlay%4$s"%5$s></span>
</a>',
esc_attr( $full_src ),
esc_attr( $attachment->post_title ),
esc_attr( $thumb_src ),
( '' !== $hover_icon ? ' et_pb_inline_icon' : '' ),
$data_icon,
$attachment->excerpt,
$attachment->post_title,
$attachment->post_name,
$attachment->post_content
);
$orientation = ( $thumb_height > $thumb_width ) ? 'portrait' : 'landscape';
$output .= sprintf(
'<div class="et_pb_gallery_item%2$s%1$s">',
esc_attr( $background_class ),
( 'on' !== $fullwidth ? ' et_pb_grid_item' : '' )
);
$output .= "
<div class='et_pb_gallery_image {$orientation}'>
$image_output
</div>";
if ( 'on' !== $fullwidth && 'on' === $show_title_and_caption ) {
if ( trim($attachment->post_title) ) {
$output .= "
<h3 class='et_pb_gallery_title'>
" . wptexturize($attachment->post_title) . "
</h3>";
}
if ( trim($attachment->post_excerpt) ) {
$output .= "
<p class='et_pb_gallery_caption'>
" . wptexturize($attachment->post_excerpt) . "
</p>";
}
}
$output .= "</div>";
}
$output .= "</div><!-- .et_pb_gallery_items -->";
if ( 'on' !== $fullwidth && 'on' === $show_pagination ) {
$output .= "<div class='et_pb_gallery_pagination'></div>";
}
$output .= "</div><!-- .et_pb_gallery -->";
return $output;
}
}
new CITTA_Builder_Module_Gallery;
<?php
// Add this to your active theme's functions.php
/*================================================
= Custom Divi Image Module =
================================================*/
function doCustomModules(){
if(class_exists("ET_Builder_Module")){
include("divi-custom-modules.php");
}
}
function prepareCustomModule(){
global $pagenow;
$is_admin = is_admin();
$action_hook = $is_admin ? 'wp_loaded' : 'wp';
$required_admin_pages = array( 'edit.php', 'post.php', 'post-new.php', 'admin.php', 'customize.php', 'edit-tags.php', 'admin-ajax.php', 'export.php' ); // list of admin pages where we need to load builder files
$specific_filter_pages = array( 'edit.php', 'admin.php', 'edit-tags.php' ); // list of admin pages where we need more specific filtering
$is_edit_library_page = 'edit.php' === $pagenow && isset( $_GET['post_type'] ) && 'et_pb_layout' === $_GET['post_type'];
$is_role_editor_page = 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'et_divi_role_editor' === $_GET['page'];
$is_import_page = 'admin.php' === $pagenow && isset( $_GET['import'] ) && 'wordpress' === $_GET['import']; // Page Builder files should be loaded on import page as well to register the et_pb_layout post type properly
$is_edit_layout_category_page = 'edit-tags.php' === $pagenow && isset( $_GET['taxonomy'] ) && 'layout_category' === $_GET['taxonomy'];
if ( ! $is_admin || ( $is_admin && in_array( $pagenow, $required_admin_pages ) && ( ! in_array( $pagenow, $specific_filter_pages ) || $is_edit_library_page || $is_role_editor_page || $is_edit_layout_category_page || $is_import_page ) ) ) {
add_action($action_hook, 'doCustomModules', 9789);
}
}
prepareCustomModule();
function get_image_sizes() {
global $_wp_additional_image_sizes;
$sizes = array();
foreach ( get_intermediate_image_sizes() as $_size ) {
if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) {
//$sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" );
//$sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" );
//$sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" );
$sizes[ $_size ] = $_size.' ('.get_option( "{$_size}_size_w" ).' x '.get_option( "{$_size}_size_h" ).')';
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
$sizes[ $_size ] = $_size.' ('.$_wp_additional_image_sizes[ $_size ]['width'].' x '.$_wp_additional_image_sizes[ $_size ]['height'].')';
}
}
return $sizes;
}
@Siddhu5096
Copy link

Hello.....Plz make this compatible with current version of divi. Its urgent. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment