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-
AuthorPosts
-
July 1, 2019 at 9:22 am #495610
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 displayIf 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
July 1, 2019 at 11:55 am #495641Second 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,
VivekJuly 1, 2019 at 4:12 pm #495699To 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.
July 1, 2019 at 4:57 pm #495718YEs, 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
July 1, 2019 at 4:58 pm #495720This reply has been marked as private.July 1, 2019 at 4:59 pm #495721I will ask the developers to comment on fallbacks for custom fields, I was not aware that they were in effect for custom fields.
July 2, 2019 at 2:17 am #495812Thanks, Alex, do please let me know .
In case the fallback is there for custom fields also, is there a way to turn it off?July 2, 2019 at 8:14 am #495843The developers will let us know
July 3, 2019 at 9:12 am #496030Hi 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
July 3, 2019 at 3:26 pm #496104Thank 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,
VivekJuly 4, 2019 at 5:42 am #496197Hello,
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
July 4, 2019 at 6:17 am #496200Thanks 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,
VivekJuly 4, 2019 at 6:45 am #496204This reply has been marked as private. -
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket