Post_images fall back order

This topic contains 12 replies, has 3 voices, and was last updated by  Kiran 5 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #495610

    vivek
    Full Member
    Post count: 246

    Hi, I understand GD post images uses teh following fallback order:
    1.If logo is set, display Company Logo image
    2.First (Featured) image uploaded to the listing post_images field
    3.CPT Category Default Listing Image
    4.CPT Default Listing Image
    5.Default listing image for Archive page display

    If I want to change it to show the first featured image before logo, ie in the order 2,1,3,4,5 , then how I can i do that, please?

    Also, if there IS an image uploaded in the post_images field as the featured image, then anyway why should the fallback sequence be triggered – so shouldn’t the sequence anyway be 2,1,3,4,5?

    thanks, Vivek

    #495641

    vivek
    Full Member
    Post count: 246

    Second query related to fallback is: I am using a custom image field (ie not post_images) in the listing hero (featured) image on the detail page.

    I do not want any fallback order for this custom field i.e if the image is there, show it , else if there is no image then leave blank (i would like even the blank featured container to now show, ie the listing body moves up.

    How can i achieve this?

    thanks,
    Vivek

    #495699

    Alex Rollin
    Moderator
    Post count: 27815

    To show the logo first, list the logo field before post_images in the types option for GD Post Images or vice versa.

    Only the post_images field has fallback images, so, don’t use that for the hero.

    #495718

    vivek
    Full Member
    Post count: 246

    YEs, Alex, as you had suggested I tried that, but even when i am using ONLY a custom image field, without post_images, still the fallback is displayed in the hero banner.

    see : https://yopune.com/competition_coaching/10662/free-mp-classes/

    I am using this to display the hero image:
    [gd_post_images type=”image”  show_title=”false”   types=”image_test” show_limit=”1″ limit=”1″]

    There is no image_test uploaded in this listing, so i would expence it to be blank. Yet, the fallback Category defuatl image is displayed here.

    Also, once i can get the ‘blank’ image, then how can i remove the white space (container) in case there is no image?

    thanks, Vivek

    #495720

    vivek
    Full Member
    Post count: 246
    This reply has been marked as private.
    #495721

    Alex Rollin
    Moderator
    Post count: 27815

    I will ask the developers to comment on fallbacks for custom fields, I was not aware that they were in effect for custom fields.

    #495812

    vivek
    Full Member
    Post count: 246

    Thanks, Alex, do please let me know .
    In case the fallback is there for custom fields also, is there a way to turn it off?

    #495843

    Alex Rollin
    Moderator
    Post count: 27815

    The developers will let us know

    #496030

    Kiran
    Moderator
    Post count: 7069

    Hi Vivek,

    You can use gd_post_meta shortcode for custom field image.

    Example:

    [gd_post_meta key="image_test" show="value" alignment="center" text_alignment="center"]

    This will display image when image_test has image to display otherwise it will show blank.

    Let us know.

    Kiran

    #496104

    vivek
    Full Member
    Post count: 246

    Thank you, Kiran- that works just like you have mentioned.

    However, using post_meta displays a much smaller image, than the post_images – i guess the container adn image size are different- see the attachments.

    Any suggestions on how to fix this and get the larger image?

    thanks,
    Vivek

    #496197

    Kiran
    Moderator
    Post count: 7069

    Hello,

    Try following snippet to display original image in post meta.

    
    
    function gd_snippet_040719_get_image_tag( $html, $id, $alt, $title, $align, $size ) {
    	global $wpdb;
    
    	if ( $size == 'medium' && empty( $align ) ) {
    		$image = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID = %d AND type != 'post_images'", $id ) );
    
    		if ( ! empty( $image ) && ( $image->type == 'image_test' ) ) {
    			$size = 'original'; // LEAVE BLANK TO SHOW ORIGINAL IMAGE.
    			$align = 'center';
    
    			$meta = isset( $image->metadata ) ? maybe_unserialize( $image->metadata ) : '';
    			$img_src = geodir_get_image_src( $image, $size );
    			$width = isset( $meta['width'] ) ? $meta['width'] : '';
    			$height = isset( $meta['height'] ) ? $meta['height'] : '';
    			$hwstring = image_hwstring( $width, $height );
    
    			$title = isset( $image->title ) && $image->title ? 'title="' .  esc_attr( wp_strip_all_tags( $image->title ) ) . '" ' : '';
    			$alt = isset( $image->caption ) && $image->caption ? esc_attr( wp_strip_all_tags( $image->caption ) ) : 'image-' . $id;
    			$class = 'align' . esc_attr( $align ) .' size-' . esc_attr( $size ) . ' geodir-image-' . $id;
    
    			$html = '<img src="' . esc_attr( $img_src ) . '" alt="' . esc_attr( $alt ) . '" ' . $title . $hwstring . 'class="' . $class . '" />';
    		}
    	}
    
    	return $html;
    }
    add_filter( 'geodir_get_image_tag', 'gd_snippet_040719_get_image_tag', 20, 6 );

    Kiran

    #496200

    vivek
    Full Member
    Post count: 246

    Thanks very much for this, Kiran

    Added this in the snippets plugin, but it seems to have no effect. e.g on this page: https://yopune.com/competition_coaching/10668/test-paid-mp-listing-with-both-logo-and-image_test-uploaded/

    thanks,
    Vivek

    #496204

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
Viewing 13 posts - 1 through 13 (of 13 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount