[wp-hackers] Return Selected Image

Robin Adrianse shorty114 at shorty114.net
Tue Dec 26 05:45:17 GMT 2006


Stripos is a php 5 only function. To achieve the same effect on php 4
i would use regex.

On 12/24/06, ryan fitzer <ryanfitzer at gmail.com> wrote:
> That got me a lot closer except for the *"Fatal error*: Call to undefined
> function: stripos()". Your help has really appreciated. I work this out.
> Thanks.
>
> Ryan
>
> On 12/24/06, Computer Guru <computerguru at neosmart.net> wrote:
> >
> > What do you want to come out?
> > The image?
> > The image address?
> > The image HTML?
> >
> > return '<span class="generic">' . getImage($selectedtext) . '</span>';
> >
> > Really straight forward PHP, nothing more I can do.
> >
> > 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 8:26 PM
> > > To: wp-hackers at lists.automattic.com
> > > Subject: Re: [wp-hackers] Return Selected Image
> > >
> > > Thanks again for the help. I afraid that I'm not savvy enough to figure
> > > this
> > > out. I've tried to implement this with no results. I'm sure it's my
> > > error.
> > > What I'm trying to return looks like this when a string of text is
> > > selected
> > >
> > > return '<span class="generic">' . $selectedtext . '</span>';
> > >
> > > But when it comes to the function you wrote, I have no idea what to
> > > substitute "$selectedtext" with.
> > >
> > > On 12/24/06, Computer Guru <computerguru at neosmart.net> wrote:
> > > >
> > > > 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
> > > >
> > > > _______________________________________________
> > > > 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
> >
> > _______________________________________________
> > 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