Skip to content

Commit

Permalink
Merge pull request #81 from kprajapatii/main
Browse files Browse the repository at this point in the history
Changes to show GD post fallback images on GD post page - CHANGED
  • Loading branch information
Stiofan authored Jul 11, 2024
2 parents ca345c4 + 1633973 commit f72edf1
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 24 deletions.
34 changes: 23 additions & 11 deletions blocks/class-blockstrap-widget-container.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,24 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
*
* @return string
*/
public function maybe_get_gd_archive_image(){
public function maybe_get_gd_archive_image() {
global $post;

$url = '';

if( defined('GEODIRECTORY_VERSION') && geodir_is_page( 'archive' ) ){
$images = geodir_get_images( 0, 1, false, '', array() , array( 'cat_default', 'cpt_default', 'listing_default' ));
if (!empty($images)) {
$url = geodir_get_image_src( $images[0], 'original' );
if ( defined( 'GEODIRECTORY_VERSION' ) ) {
if ( geodir_is_page( 'single' ) && ! empty( $post->ID ) ) {
$images = geodir_get_images( (int) $post->ID, 1, true, 0, array( 'post_images' ) );

if ( ! empty( $images ) ) {
$url = geodir_get_image_src( $images[0], 'full' );
}
} else if ( geodir_is_page( 'archive' ) ) {
$images = geodir_get_images( 0, 1, false, '', array(), array( 'cat_default', 'cpt_default', 'listing_default' ) );

if ( ! empty( $images ) ) {
$url = geodir_get_image_src( $images[0], 'full' );
}
}
}

Expand All @@ -380,15 +391,16 @@ public function maybe_get_gd_archive_image(){
*
* @return string
*/
public function maybe_get_gd_location_image(){
public function maybe_get_gd_location_image() {
global $geodirectory;

$url = '';
if( defined('GEODIRLOCATION_VERSION') && geodir_is_page( 'location' ) ){
global $geodirectory;

if ( defined( 'GEODIRLOCATION_VERSION' ) && geodir_is_page( 'location' ) ) {
$attachment = GeoDir_Location_SEO::get_post_attachment( $geodirectory->location );
if (!empty($attachment)) {
$upload_dir = wp_get_upload_dir();
$url = esc_url($upload_dir['baseurl'] . $attachment->file );

if ( ! empty( $attachment ) ) {
$url = esc_url( geodir_get_image_src( $attachment , 'full' ) );
}
}

Expand Down
34 changes: 24 additions & 10 deletions blocks/class-blockstrap-widget-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
$image_class .= ! empty( $args['img_aspect'] ) ? ' embed-responsive-item' : '';

// image mask
$image_styles = ! empty( $args['img_mask'] ) ? '-webkit-mask-image: url("' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . '/assets/masks/' . esc_attr( $args['img_mask'] ) . '.svg");' : '';
$image_styles = ! empty( $args['img_mask'] ) ? '-webkit-mask-image: url("' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . 'assets/masks/' . esc_attr( $args['img_mask'] ) . '.svg");' : '';
$image_styles .= ! empty( $args['img_mask'] ) ? '-webkit-mask-size: contain;-webkit-mask-repeat: no-repeat;' : '';
$image_styles .= ! empty( $args['img_mask'] ) && ! empty( $args['img_mask_position'] ) ? '-webkit-mask-position: ' . esc_attr( $args['img_mask_position'] ) . ';' : '';
$image_style = $image_styles ? "style='$image_styles'" : '';
Expand Down Expand Up @@ -600,21 +600,39 @@ public function output( $args = array(), $widget_args = array(), $content = '' )

$link_image_src_arr = wp_get_attachment_image_src( absint( $args['img_image_id'] ), $lightbox_size );
$link_image_src = ! empty( $link_image_src_arr[0] ) ? esc_url_raw( $link_image_src_arr[0] ) : '';

}

if ( ! $image_src && $this->is_block_content_call() ) {
$image = '<img src="' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . '/assets/images/block-image-placeholder.jpg" class="' . sd_sanitize_html_classes( $image_class ) . '" />';
$image = '<img src="' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . 'assets/images/block-image-placeholder.jpg" class="' . sd_sanitize_html_classes( $image_class ) . '" />';
} elseif ( ! $image ) {

if ( 'featured' === $args['img_src'] && 'upload' === $args['fallback_img_src'] && ! empty( $args['fallback_img_image_id'] ) ) {
$image = wp_get_attachment_image( absint( $args['fallback_img_image_id'] ), $image_size, false, $img_attr );
$image_src_arr = wp_get_attachment_image_src( absint( $args['fallback_img_image_id'] ), 'large' );
$image_src = ! empty( $image_src_arr[0] ) ? esc_url_raw( $image_src_arr[0] ) : '';
} elseif ( 'featured' === $args['img_src'] && 'default' === $args['fallback_img_src'] ) {
$image_src = BLOCKSTRAP_BLOCKS_PLUGIN_URL . '/assets/images/block-image-placeholder.jpg';
$post_image = array();

if ( ! empty( $post ) && ! empty( $post->post_type ) && function_exists( 'geodir_is_gd_post_type' ) && geodir_is_gd_post_type( $post->post_type ) ) {
$post_images = geodir_get_images( (int) $post->ID, 1, true, 0, array( 'post_images' ) );

if ( ! empty( $post_images ) ) {
$post_image = $post_images[0];

$image_src = geodir_get_image_src( $post_image, $image_size );
$link_image_src = geodir_get_image_src( $post_image, $lightbox_size );
}
}

if ( ! $image_src ) {
$image_src = BLOCKSTRAP_BLOCKS_PLUGIN_URL . 'assets/images/block-image-placeholder.jpg';
}

if ( ! $img_alt ) {
$img_alt_tag = 'alt="' . __( 'Placeholder image', 'blockstrap-page-builder-blocks' ) . '"';
if ( ! empty( $post_image ) && ! empty( $post_image->title ) ) {
$img_alt_tag = 'alt="' . esc_attr( wp_strip_all_tags( stripslashes_deep( $post_image->title ) ) ) . '"';
} else {
$img_alt_tag = 'alt="' . __( 'Placeholder image', 'blockstrap-page-builder-blocks' ) . '"';
}
}
$image = '<img src="' . esc_url_raw( $image_src ) . '" class="' . sd_sanitize_html_classes( $image_class ) . '" ' . $img_alt_tag . ' ' . $img_lazy_tag . ' />';
} else {
Expand Down Expand Up @@ -699,10 +717,7 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
);

return $image ? $figure : '';

}


}

// register it.
Expand All @@ -712,4 +727,3 @@ function () {
register_widget( 'BlockStrap_Widget_Image' );
}
);

2 changes: 1 addition & 1 deletion blocks/class-blockstrap-widget-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function output( $args = array(), $widget_args = array(), $content = '' )
$wrap_styles = sd_build_aui_styles( $args );

// map mask
$wrap_styles .= ! empty( $args['mask'] ) ? '-webkit-mask-image: url("' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . '/assets/masks/' . esc_attr( $args['mask'] ) . '.svg");' : '';
$wrap_styles .= ! empty( $args['mask'] ) ? '-webkit-mask-image: url("' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . 'assets/masks/' . esc_attr( $args['mask'] ) . '.svg");' : '';
$wrap_styles .= ! empty( $args['mask'] ) ? '-webkit-mask-size: contain;-webkit-mask-repeat: no-repeat;' : '';
$wrap_styles .= ! empty( $args['mask'] ) && ! empty( $args['mask_position'] ) ? '-webkit-mask-position: ' . esc_attr( $args['mask_position'] ) . ';' : '';

Expand Down
4 changes: 2 additions & 2 deletions blocks/class-blockstrap-widget-navbar-brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct() {
'class' => '',
'alt' => __( 'Site logo', 'blockstrap-page-builder-blocks' ),
'element_require' => '[%icon_image%]!=""',
'if_src' => '[%icon_image%]==="Blockstrap-white.png" ? "' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . '/assets/images/Blockstrap-white.png" : [%icon_image%]',
'if_src' => '[%icon_image%]==="Blockstrap-white.png" ? "' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . 'assets/images/Blockstrap-white.png" : [%icon_image%]',
'style' => '{maxWidth:\'[%img_max_width%]px\'}',
'width' => '[%img_max_width%]',
'height' => '50',
Expand All @@ -54,7 +54,7 @@ public function __construct() {
'class' => '',
'alt' => __( 'Site logo', 'blockstrap-page-builder-blocks' ),
'element_require' => '[%icon_image%]!=""',
'if_src' => '[%icon_image%]==="Blockstrap-white.png" ? "' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . '/assets/images/Blockstrap-white.png" : [%icon_image%]',
'if_src' => '[%icon_image%]==="Blockstrap-white.png" ? "' . BLOCKSTRAP_BLOCKS_PLUGIN_URL . 'assets/images/Blockstrap-white.png" : [%icon_image%]',
'style' => '{maxWidth:\'[%img_max_width%]px\'}',
'width' => '[%img_max_width%]',
'height' => '50',
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ Automatic updates should work seamlessly. To avoid unforeseen problems, we alway
= 0.1.20 - TBD =
* BS Container has `undefined` class if style ID not set - FIXED
* JS error in rating block breaks modal functionality - FIXED
* Changes to show GD post fallback images on GD post page - CHANGED

= 0.1.19 =
* BS > Offcanvas block added for creating Offcanvas items - ADDED
Expand Down

0 comments on commit f72edf1

Please sign in to comment.