Plugin Directory

Changeset 715246


Ignore:
Timestamp:
05/19/2013 02:27:37 PM (13 years ago)
Author:
leethompson
Message:

Removed the need for featured image, if not featured image is set then use first image in post

Location:
lazy-pinner
Files:
1 added
4 edited
7 copied

Legend:

Unmodified
Added
Removed
  • lazy-pinner/tags/2.1/includes/pinit.php

    r712087 r715246  
    22include('auth.php');
    33
     4
     5// POST IMAGE
     6function get_default_post_image($size = 'thumbnail', $post_id = false){
     7    global $post, $id;
     8    $post_id = (int)$post_id;
     9    if (!$post_id) $post_id = $post->ID;
     10    $image = '';
     11    if(has_post_thumbnail($post_id)) {
     12        $image = get_the_post_thumbnail_src(get_the_post_thumbnail($post_id, $size));
     13    } else {
     14        $args = array(
     15            'post_parent' => $post_id
     16            , 'post_type' => 'attachment'
     17            , 'post_mime_type' => 'image'
     18            , 'post_status' => 'any'
     19            , 'numberposts' => 1
     20            , 'order' => 'ASC'
     21 
     22        );
     23        $attachments = get_children($args);
     24        foreach($attachments as $attachment) {
     25            //$attachment = array_shift($attachments);
     26            $image = wp_get_attachment_image_src($attachment->ID, $size);
     27        $image = $image[0];
     28               
     29        }
     30    }
     31    return $image;
     32}
    433
    534function get_the_post_thumbnail_src($img)
     
    1342    $desc = get_the_title();
    1443    $link = get_permalink();
    15     $imgurl = get_the_post_thumbnail_src(get_the_post_thumbnail());
     44    $imgurl =  get_default_post_image($image);
     45    //$imgurl = get_the_post_thumbnail_src(get_the_post_thumbnail());
    1646        $baseurl = get_site_url();
    1747    $table = $wpdb->prefix . 'lazy_pinner_user';
  • lazy-pinner/tags/2.1/lazypinner.php

    r714191 r715246  
    44Plugin URI: http://www.biofects.com
    55Description: This plugin automatically post your image and title to pineterst on Publish or Save
    6 Version: 2.0
     6Version: 2.1
    77Author: Lee Thompson and Nick Westerlund
    88Author URI: http://www.biofects.com
  • lazy-pinner/tags/2.1/readme.txt

    r714191 r715246  
    55Requires at least: 3.0
    66Tested up to: 3.5.1
    7 Stable tag: 2.0
     7Stable tag: 2.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    31311. This script requires your host to have mcrypt, this is to encrypt passwords saved in the database.
    3232
    33 2. This does require your theme to use the_post_thumbnail function. Please see http://codex.wordpress.org/Function_Reference/the_post_thumbnail.
    34 
    35 3. Issues of safe_mode or open_basedir defined (I will fix this in next release).
     332. Issues of safe_mode or open_basedir defined (I will fix this in next release).
    3634
    3735= Why two developers =
     
    5654= 2.0 =
    5755This major release has a lot of changes. Dont worry it will not impact any setting you have done already. I have made entering your pinterest info easier. I have created a page for logs.
     56
     57= 2.1 =
     58I have made the pinner find the first image attached if no featured image is set, this removes the need to posts to have featured image.
  • lazy-pinner/trunk/includes/pinit.php

    r712087 r715246  
    22include('auth.php');
    33
     4
     5// POST IMAGE
     6function get_default_post_image($size = 'thumbnail', $post_id = false){
     7    global $post, $id;
     8    $post_id = (int)$post_id;
     9    if (!$post_id) $post_id = $post->ID;
     10    $image = '';
     11    if(has_post_thumbnail($post_id)) {
     12        $image = get_the_post_thumbnail_src(get_the_post_thumbnail($post_id, $size));
     13    } else {
     14        $args = array(
     15            'post_parent' => $post_id
     16            , 'post_type' => 'attachment'
     17            , 'post_mime_type' => 'image'
     18            , 'post_status' => 'any'
     19            , 'numberposts' => 1
     20            , 'order' => 'ASC'
     21 
     22        );
     23        $attachments = get_children($args);
     24        foreach($attachments as $attachment) {
     25            //$attachment = array_shift($attachments);
     26            $image = wp_get_attachment_image_src($attachment->ID, $size);
     27        $image = $image[0];
     28               
     29        }
     30    }
     31    return $image;
     32}
    433
    534function get_the_post_thumbnail_src($img)
     
    1342    $desc = get_the_title();
    1443    $link = get_permalink();
    15     $imgurl = get_the_post_thumbnail_src(get_the_post_thumbnail());
     44    $imgurl =  get_default_post_image($image);
     45    //$imgurl = get_the_post_thumbnail_src(get_the_post_thumbnail());
    1646        $baseurl = get_site_url();
    1747    $table = $wpdb->prefix . 'lazy_pinner_user';
  • lazy-pinner/trunk/lazypinner.php

    r714191 r715246  
    44Plugin URI: http://www.biofects.com
    55Description: This plugin automatically post your image and title to pineterst on Publish or Save
    6 Version: 2.0
     6Version: 2.1
    77Author: Lee Thompson and Nick Westerlund
    88Author URI: http://www.biofects.com
  • lazy-pinner/trunk/readme.txt

    r714191 r715246  
    55Requires at least: 3.0
    66Tested up to: 3.5.1
    7 Stable tag: 2.0
     7Stable tag: 2.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    31311. This script requires your host to have mcrypt, this is to encrypt passwords saved in the database.
    3232
    33 2. This does require your theme to use the_post_thumbnail function. Please see http://codex.wordpress.org/Function_Reference/the_post_thumbnail.
    34 
    35 3. Issues of safe_mode or open_basedir defined (I will fix this in next release).
     332. Issues of safe_mode or open_basedir defined (I will fix this in next release).
    3634
    3735= Why two developers =
     
    5654= 2.0 =
    5755This major release has a lot of changes. Dont worry it will not impact any setting you have done already. I have made entering your pinterest info easier. I have created a page for logs.
     56
     57= 2.1 =
     58I have made the pinner find the first image attached if no featured image is set, this removes the need to posts to have featured image.
Note: See TracChangeset for help on using the changeset viewer.