[wp-hackers] Return Selected Image

Computer Guru computerguru at neosmart.net
Sun Dec 24 17:25:02 GMT 2006


Actually, it's not too difficult:

<?php
function getImage($img) {
    /* Function to get image from HTML source
     * Accepts $img with either " or ' as attribute enclosure
     * e.g. $img = '<img src="http://blabla.com/my.png" />';
     * or $img = "<img src='http://blabla.com/my.png' />";
     */
    $img = str_replace("\"", "'", $img); //Replace all " with '
    $begin = stripos($img, "src='") + 5;
    $img = substr($img, $begin);
    $end = stripos($img, "'");
    $img = substr($img, 0, $end);
    return $img;
}
?>

Computer Guru
NeoSmart Technologies
http://neosmart.net/blog/


> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-
> bounces at lists.automattic.com] On Behalf Of ryan fitzer
> Sent: Sunday, December 24, 2006 7:08 PM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] Return Selected Image
> 
> Thanks Computer Guru. I was hoping for a nice and neat variable like
> $selectedimage or something. Oh well. I'll start digging around and
> figure
> it out. Thanks for the help.
> 
> Ryan
> 
> On 12/24/06, Computer Guru <computerguru at neosmart.net> wrote:
> >
> > Technically an image *is* text, right? It's an <img> tag, so you
> should
> > just
> > grab the HTML and use PHP string functions to grab the image source
> from
> > the
> > img tag.
> >
> > Computer Guru
> > NeoSmart Technologies
> > http://neosmart.net/blog/
> >
> >
> > > -----Original Message-----
> > > From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-
> > > bounces at lists.automattic.com] On Behalf Of ryan fitzer
> > > Sent: Sunday, December 24, 2006 9:16 AM
> > > To: wp-hackers at lists.automattic.com
> > > Subject: [wp-hackers] Return Selected Image
> > >
> > > I'm very new to writing plugins (actually just altering) and I'm
> trying
> > > to
> > > figure out how to return a selected image wrapped in a span element
> in
> > > the
> > > rich text editor. I've got selected text working by using
> $selectedtext
> > > ,
> > > but what about when a user selects and image in a post? Thanks for
> your
> > > help.
> > >
> > > --
> > > Ryan Fitzer
> > > Dallas, TX
> > > http://www.ryanfitzer.com
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> 
> 
> 
> --
> Ryan Fitzer
> Dallas, TX
> http://www.ryanfitzer.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list