• Resolved jomo

    (@jonathanmoorebcsorg)


    Is there any reason not to set the wordpress featured image to the selected listing image?

    eg: class-listing.php function set_thumbnail_id()
    add line:
    set_post_thumbnail( $this->id, $image_id );
    to set the standard wordpress featured image.

    Then themes with views using wordpress featured image can make use of it.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi @jonathanmoorebcsorg,

    Yes, actually, there is a reason.

    While we are a custom post type, as you noted, not all themes uniformly handle the “featured image” in a way that we can predict.

    Instead, we handle our own images because that’s the only way we can guarantee that the image is something only we control when a listing needs to be deleted. If we use Featured Images or anything from the Media Library, we can’t get rid of the associated images since they *might* be shared and we have no way to detect this.

    Instead, we have a “featured image” image that we use when a listing is marked as “featured/sticky”. It is replaceable in the code now, and will be a setting in the future so you can override it.

    Does that make more sense?

    Please let me know if you have any other questions.

    Thread Starter jomo

    (@jonathanmoorebcsorg)

    ok I understand but I have one doubt over the logic:

    Some plugins accepting user images do not store the images in the Media Library, in order to have complete control and separation of the images which belong to a particular user/group/listing.

    I expected that Business Directory would do this, however I was surprised to fine the pictures uploaded on the listings are available in the Media Library, so indeed they could be then used on other pages etc and there would be no easy way to detect this.

    (or does this depend on the permission level of the user or a setting I didn’t notice?)

    Yes I fully understand for featured images some themes may have particular requirements for square or portrait or landscape pictures of particular size, an option may be best.

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Hi @jonathanmoorebcsorg,

    Well, after a discussion with my developer, apparently I’ve been living in a time warp. We’ve been using the Media library for quite some time now because they handle all of the resizing issues that we struggled with before. So I have to take back what I said about why we’re not using ML because apparently, we are. 🙁

    That being said, the Featured Image issue is still the same–but the reason is different. Here’s what my developer said on the issue:

    We didn’t do this since the beginning because WP Featured Images were introduced after we started using the Media Library.
    Also, there’s a possible conflict here: WP featured images are configured using an admin-side metabox, so nothing prevents admins from manually changing the featured image to any image from the Media Library (even outside of the listing’s images). If we then force the featured image to be the one configured via BD, this configuration would be lost. Our “featured image” would always override the one set for the post.

    So that’s where we’re at today. In the future, we may consider changing that behavior but right now, that’s how it works.

    Thread Starter jomo

    (@jonathanmoorebcsorg)

    I think the better reason for not setting featured image would be the possible conflict with theme required image sizes.

    Please note however, the main reason for setting the featured image is SEO: when the post featured image is set, the site tools will detect the featured image and output the relevant OpenGraph meta information. This means the featured image appears when sharing the entry to Facebook and other social media platforms etc.

    The fallback is normally content image or site default image. This may be inappropriate, listees may be unhappy that their listing appears (when shared) with the site branding rather than their own image, so if there is no featured image, site owners might want to extend their image searching functions to explicitly search for business directory images, if that’s possible.

    At the moment I’d be sticking with the one-line hack to the set_post_thumbnail( $this->id, $image_id ); which seems a lot simpler.

    Plugin Author Business Directory Plugin

    (@businessdirectoryplugin)

    Yep, understood. Again, something we can consider for the future.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Set WordPress featured image’ is closed to new replies.