WordPress.org

Ready to get started?Download WordPress

Forums

Taxonomy Images
Get image associated to a specific "Term ID" or "Category I (7 posts)

  1. Marten_R_K
    Member
    Posted 2 years ago #

    Get image associated to a specific "Term ID" or "Category ID"

    Hi!
    This is a great plugin worthy of the high ranking it has received.
    However, there is one usage scenario that is overlooked, (at least according to what I can find/figure out).

    I want my category archive page to display the image associated with the specific category ID that the user is currently browsing.

    The only solution for that was to use the now depricated function get_image_html, which had a third paramater for the category ID.

    $img_2 = $taxonomy_images_plugin->get_image_html( 'fullsize',$cat_id );

    And this function does not provide the same added functionality as the filters.

    If you ask me the best scenario would be to add a third parameter to the filters that would specify exactly which category-id or term-id to get the image info from.

    I'm not good enough to start modifying the plugin files, but I would very much appreciate if someone pointed me to a solution, or perhaps even updated the plugin.

    Best regards
    Mårten

    http://wordpress.org/extend/plugins/taxonomy-images/

  2. Michael Fields
    Themer
    Plugin Author

    Posted 2 years ago #

    Are you talking about having the image display in category.php? If so the following code should work for you:

    <?php echo apply_filters( 'taxonomy-images-queried-term-image', '', array(
    'size' => 'post-thumbnail',
    'before' => '<div id="featured-image">',
    'after' => '</div>',
    ) ); ?>

    You may need to adjust the size parameter :)

    The only solution for that was to use the now depricated function get_image_html, which had a third paramater for the category ID.

    EEK! Please do not do that ... that function is really, really old!

  3. Marten_R_K
    Member
    Posted 2 years ago #

    Hi!, thanks for a quick answer.

    However, I'm looking to display a list of specific categories together with their images,For example:
    - parent category,
    - currently queried category
    - children categories.
    - specific category
    - specific category

    I have no problem listing my categories like that as regular links, but it would improve the looks of my site immensely if I could include the category images in that layout.

    I'm not very experienced with PHP and wordpress coding, perhaps the best strategy is to manipulate the query somehow before each run of the filter? (maybe that's what you are actually intending?)

    I'm very grateful for the likes of you, who are making the web accessible to us newbs.

    //M

  4. Marten_R_K
    Member
    Posted 2 years ago #

    Bump.

    I really like this plugin, the UI and construcion is really good, but I don't want to use the depreciated and also rather limited function call I mentioned.

    Does anynody have any suggestions for how to solve my problem.

    Isn't there a way to just fetch the image associated with a specific taxonomy ?

    Best regards
    Mårten

  5. viter-z-bayraku
    Member
    Posted 2 years ago #

    add this function to public-filters.php:

    function tip_plugin_get_terms($term_id) {
     	$associations = taxonomy_image_plugin_get_associations();
    	$tt_id = absint( $term_id );
    	$img_id = false;
    	if ( array_key_exists( $tt_id, $associations ) ) {
    		$img_id = absint( $associations[$tt_id] );
    	}
    	return $img_id;
     }

    Call term image id by:
    $img_id = tip_plugin_get_terms($term_id);

  6. ROHIT-07
    Member
    Posted 2 years ago #

    Thanks Alot :- @Marten_R_K
    for your sourceful Post. That one line code made my day.

  7. Marten_R_K
    Member
    Posted 2 years ago #

    @viter-z-bayraku
    Super sweet!
    I have only had time to briefly test your code but it seems to do the trick.
    You made my day. And I would say this issue could be marked as resolved.

    For general information, I used the wp_get_attachment_image_src to display the image associated with the image-id paramater.

    Thanks to everyone.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic