[resolved] Get post_thumbnail in list or slider (4 posts)

  1. -creynolds-aiec
    Posted 3 years ago #

    I'd love to use the list or slider option for my theme's slider. The problem is I need to pull a custom image size created with the add_image_size() function. If there is a way to do this my meager google-fu skills are failing me?

    Thanks in advance for any help.


  2. Derek Herman
    Plugin Author

    Posted 3 years ago #

    Off the top of my head... You would need to add the add_image_size() function to the functions.php and then write some PHP that will grab the image ID using the url of the image in the slider then use wp_get_attachment_image() to get the correct size.

  3. -creynolds-aiec
    Posted 3 years ago #

    Awesome thanks for the help Derek.
    I used this function

    function get_attachment_id_from_src ($image_src) {
            global $wpdb;
            $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'";
            $id = $wpdb->get_var($query);
            return $id;

    I found it here:

    and this to get the image

    $attachmentid = get_attachment_id_from_src ($slide['img']);
       $custom = wp_get_attachment_image_src( $attachmentid, 'orbit-custom' );
                        <img src="' <?php echo $custom[0] ?>" />

    Of course I used the add_image_size to create the orbit-custom

  4. -creynolds-aiec
    Posted 3 years ago #

    forgot to mark as resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • OptionTree
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic