WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. -creynolds-aiec
    Member
    Posted 1 year 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.

    http://wordpress.org/extend/plugins/option-tree/

  2. Derek Herman
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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:
    http://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url

    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
    Member
    Posted 1 year ago #

    forgot to mark as resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic