View Single Post
Old 05-16-2009, 08:06 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,588
im in a giving mood today.

[sharelink] in your post or page will create the share link(s) like on lolcats, and it will take use the attached image, so no need for custom fields.

Code:
<?php

function sharelink_shortcode($content)
{
    $attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));
    $img = array_shift($attachments);
    $imagelink = wp_get_attachment_image_src($img->ID,'full');
    $image = $imagelink[0];
    $permalink = get_permalink();
    $home = get_bloginfo('home');
    $content = 'Link: <input type="text" value="'.$permalink.'" size="30"><br/><br/>';
    $content .= 'Image Code: <input type="text" size="45" value="<a href=&quot;'.$home.'&quot;><img src=&quot;'.$image.'&quot; border=&quot;0&quot; alt=&quot;funny pics&quot;></a>">'; 
    return $content;
}

add_shortcode('sharelink','sharelink_shortcode');

?>
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


My Cam Feeds Script / Gallery Scraper / WPXXX Theme / Free Templates
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote