Skip to content

Commit

Permalink
updated preview image section
Browse files Browse the repository at this point in the history
  • Loading branch information
Syed Galib committed Feb 24, 2020
1 parent b6f76f7 commit aed650a
Show file tree
Hide file tree
Showing 11 changed files with 275 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
languages/directorist-en_GB-backup-202002180310410.po~
languages/directorist-en_GB.mo
languages/directorist-en_GB.po
languages/directorist-en_GB-backup-202002181356150.po~
40 changes: 19 additions & 21 deletions admin/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ jQuery(function ($) {


//Display filter button
var lf_opt7 = $("#default_preview_image,#crop_width,#crop_height,#way_to_show_preview,#prv_background_type");
var lf_opt7 = $("#default_preview_image,#crop_width,#crop_height, div#prv_container_size_by, #way_to_show_preview,#prv_background_type");
lf_opt7.hide();
$('input[name="display_preview_image"]').on("change", function () {
if($(this).is(":checked") === true){
Expand All @@ -646,7 +646,7 @@ jQuery(function ($) {


//Preview image
var fill = $("#crop_width,#crop_height");
var fill = $("#crop_width, #crop_height, div#prv_container_size_by");
var backType = $("#prv_background_type");
var backgroundType = $("#prv_background_color");
backgroundType.hide();
Expand Down Expand Up @@ -1602,25 +1602,6 @@ jQuery(function ($) {
});
});


// Single Slider - Display Dependency Options For Slider Image
var dsiplay_slider_single_page_inp = $('input[name="dsiplay_slider_single_page"]');
var dsiplay_slider_single_page_dep = $("#single_slider_image_size, #dsiplay_thumbnail_img, #gallery_crop_width, #gallery_crop_height");

dsiplay_slider_single_page_inp.on("change", function () {
if ( $(this).is(":checked") === true ) {
dsiplay_slider_single_page_dep.show();
} else {
dsiplay_slider_single_page_dep.hide();
}
});

dsiplay_slider_single_page_dep.hide();
if ( dsiplay_slider_single_page_inp.is(":checked")) {
dsiplay_slider_single_page_dep.show();
}


// Single Slider - Display Background Type Options
var single_slider_image_size_inp = $('select[name="single_slider_image_size"]');
var single_slider_background_type_wrap = $("#single_slider_background_type");
Expand Down Expand Up @@ -1655,4 +1636,21 @@ jQuery(function ($) {
single_slider_background_color_wrap.show();
}

// Single Slider - Display Dependency Options For Slider Image
var dsiplay_slider_single_page_inp = $('input[name="dsiplay_slider_single_page"]');
var dsiplay_slider_single_page_dep = $("div#single_slider_image_size, div#dsiplay_thumbnail_img, div#gallery_crop_width, div#gallery_crop_height, div#single_slider_background_color");

dsiplay_slider_single_page_inp.on("change", function () {
if ( $(this).is(":checked") === true ) {
dsiplay_slider_single_page_dep.show();
} else {
dsiplay_slider_single_page_dep.hide();
}
});

dsiplay_slider_single_page_dep.hide();
if ( dsiplay_slider_single_page_inp.is(":checked")) {
dsiplay_slider_single_page_dep.show();
}

});
1 change: 1 addition & 0 deletions directorist-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ private function setup_constants()
*/
private function includes()
{
// $helper = new ATBDP_Helper;
require_once ATBDP_TEMPLATES_DIR . 'single-template-shortcode.php';
require_once ATBDP_LIB_DIR . 'vafpress/bootstrap.php'; // load option framework.
require_once ATBDP_INC_DIR . 'helper-functions.php';
Expand Down
85 changes: 68 additions & 17 deletions includes/classes/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public static function get_plasma_slider( $args )

// Default
$data['show-slider'] = get_directorist_option('dsiplay_slider_single_page', true);
$is_enabled = ( $data['show-slider'] == true || $data['show-slider'] === '1' ) ? true : false ;

if ( !$is_enabled ) {
return '';
}

if ( $data['show-slider'] !== true && $data['show-slider'] !== '1' ) {
return '';
}
Expand Down Expand Up @@ -74,12 +79,6 @@ public static function get_plasma_slider( $args )
if ( isset($args['p_title']) ) {
$data['alt'] = $args['p_title'];
}
if ( isset($args['custom_gl_width']) ) {
$data['width'] = $args['custom_gl_width'];
}
if ( isset($args['custom_gl_height']) ) {
$data['height'] = $args['custom_gl_height'];
}
if ( isset($args['thumbnail-background-color']) ) {
$data['thumbnail-background-color'] = $args['thumbnail-background-color'];
}
Expand All @@ -90,12 +89,7 @@ public static function get_plasma_slider( $args )
$padding_top = $data['height'] / $data['width'] * 100;
$data['padding-top'] = $padding_top;

ob_start();
self::view('plasma-slider', $data);
$slider = ob_get_contents();
ob_end_clean();

return $slider;
return self::get_view('plasma-slider', $data);
}

public static function view( $file_path, $data = null )
Expand All @@ -106,6 +100,17 @@ public static function view( $file_path, $data = null )
}
}

public static function get_view( $file_path, $data = null )
{
$view = '';
ob_start();
self::view( $file_path, $data );
$view = ob_get_contents();
ob_end_clean();

return $view;
}

// get_default_slider
public static function get_default_slider( $args )
{
Expand Down Expand Up @@ -188,12 +193,50 @@ public static function the_thumbnail_card($img_src = '', $_args = array())
$is_blur = get_directorist_option('prv_background_type', 'blur');
$is_blur = ('blur' === $is_blur ? true : false);
$alt = esc_html(get_the_title());
$image_size = get_directorist_option('way_to_show_preview', 'contain'); // contain / full / cover
$container_size_by = get_directorist_option('prv_container_size_by', 'px');
$by_ratio = ( 'px' === $container_size_by ) ? false : true;
$image_size = get_directorist_option('way_to_show_preview', 'cover'); // contain / full / cover
$ratio_width = get_directorist_option('crop_width', 360);
$ratio_height = get_directorist_option('crop_height', 300);
$blur_background = $is_blur;
$background_color = get_directorist_option('prv_background_color', 'gainsboro');
$image = $img_src;

$listing_img = get_post_meta(get_the_ID(), '_listing_img', true);
$listing_img_src = wp_get_attachment_image_src($listing_img[0], 'medium')[0];

$listing_prv_img = get_post_meta(get_the_ID(), '_listing_prv_img', true);
$prv_image_src = wp_get_attachment_image_src($listing_prv_img, 'medium')[0];

$default_image_src = get_directorist_option('default_preview_image', ATBDP_PUBLIC_ASSETS . 'images/grid.jpg');

if ( 'cover' === $image_size ) {
$listing_img_src = atbdp_image_cropping($listing_img, $ratio_width, $ratio_height, true, 100)['url'];
$prv_image_src = atbdp_image_cropping($listing_prv_img, $ratio_width, $ratio_height, true, 100)['url'];
$default_image_src = atbdp_image_cropping($default_image_src, $ratio_width, $ratio_height, true, 100)['url'];
}

$has_thumbnail = false;
$thumbnail_img = '';

if (!empty($listing_img[0]) && empty($listing_prv_img_src)) {
$thumbnail_img = $listing_img_src;
$has_thumbnail = true;
}
if (empty($listing_img[0]) && empty($listing_prv_img_src) && !empty($default_image_src)) {
$thumbnail_img = $default_image_src;
$has_thumbnail = true;
}
if (!empty($listing_prv_img)) {
$thumbnail_img = $prv_image_src;
$has_thumbnail = true;
}
if (!empty($img_src)) {
$thumbnail_img = $img_src;
$has_thumbnail = true;
}

if ( !$has_thumbnail ) { return ''; }
$image = $thumbnail_img;

// Extend Default
if ( isset($args['image']) ) {
Expand All @@ -220,9 +263,17 @@ public static function the_thumbnail_card($img_src = '', $_args = array())

// Style
$style = '';
$padding_top_value = (int) $ratio_height / (int) $ratio_width * 100;
$padding_top_css = "padding-top: $padding_top_value%;";
$style .= $padding_top_css;

if ( $by_ratio ) {
$padding_top_value = (int) $ratio_height / (int) $ratio_width * 100;
$padding_top_css = "padding-top: $padding_top_value%;";
$style .= $padding_top_css;
} else {
$height_value = (int) $ratio_height;
$height_css = "height: {$height_value}px;";
$style .= $height_css;
}

$background_color_css = '';
if ( $image_size !== 'full' && !$blur_background ) {
$background_color_css = "background-color: $background_color";
Expand Down
2 changes: 1 addition & 1 deletion includes/classes/class-image-resizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function resize($width, $height, $crop = true, $quality = 100)

// Bail if we don't have an attachment URL
if ( ! $attachmentUrl) {
return array('url' => $attachmentUrl, 'width' => $width, 'height' => $height);
return array('url' => $this->attachmentId, 'width' => $width, 'height' => $height);
}

// Get the image file path
Expand Down
25 changes: 22 additions & 3 deletions includes/classes/class-settings-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@ function get_archive_page_settings_fields()
'name' => 'display_preview_image',
'label' => __('Show Preview Image', 'directorist'),
'description' => __('Hide/show preview image from all listing page.', 'directorist'),
'default' => 1,
'default' => 'px',
),

'way_to_show_preview' => array(
Expand Down Expand Up @@ -3073,7 +3073,7 @@ function get_archive_page_settings_fields()
array(
'type' => 'slider',
'name' => 'crop_width',
'label' => __('Image Width', 'directorist'),
'label' => __('Container Width', 'directorist'),
'min' => '1',
'max' => '1200',
'step' => '1',
Expand All @@ -3082,12 +3082,31 @@ function get_archive_page_settings_fields()
array(
'type' => 'slider',
'name' => 'crop_height',
'label' => __('Image Height', 'directorist'),
'label' => __('Container Height', 'directorist'),
'min' => '1',
'max' => '1200',
'step' => '1',
'default' => '260',
),
array(
'type' => 'select',
'name' => 'prv_container_size_by',
'label' => __('Container Size By', 'directorist'),
'items' => array(
array(
'value' => 'px',
'label' => __('Pixel', 'directorist'),
),
array(
'value' => 'ratio',
'label' => __('Ratio', 'directorist'),
),
),
'default' => array(
'value' => 'px',
'label' => __('Pixel', 'directorist'),
),
),
array(
'type' => 'select',
'name' => 'prv_background_type',
Expand Down
Loading

0 comments on commit aed650a

Please sign in to comment.