GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP guys - help, please (https://gfy.com/showthread.php?t=912730)

sheepish 06-26-2009 12:14 AM

PHP guys - help, please
 
Good morning board. As if I wasn't bald enough already, I'm trying to modify my blogs and coming across a problem...

At the moment I have a lot of posts with thumbnail images that, when clicked, just are linked to themselves i.e. bringing up that image in a new window. What I'm after is a way of modifing wordpress so that when the image is clicked, the clicker gets sent to a specific URL.

I have found the regex that selects the <a href... through to the /a> and can change it but I need a way to keep the <img src...> the same.

Allegedly the code below in your template can be used to remove the img src - can it be modified to change the a href but keep the img src?

PHP Code:

<?php   
$content 
get_the_content();   
$postOutput preg_replace('/<img[^>]+./',''$content);   
echo 
$postOutput;   
?>

Any thoughts?

Cheers

M.

fallenmuffin 06-26-2009 12:34 AM

You can play with '<a href="([^"]+)">([^<]+)<\/a>' and see what you can do with it. Too tired/lazy to code it up.

2012 06-26-2009 12:42 AM

so you want us to help you remove all the "link codes" in your images ... neat

2012 06-26-2009 12:54 AM


sheepish 06-26-2009 01:11 AM

Quote:

Originally Posted by fartfly (Post 16001061)
so you want us to help you remove all the "link codes" in your images ... neat

Not all, no but you're on the correct lines.

quantum-x 06-26-2009 02:22 AM

Quote:

Originally Posted by fallenmuffin (Post 16001056)
You can play with '<a href="([^"]+)">([^<]+)<\/a>' and see what you can do with it. Too tired/lazy to code it up.

That's a terrible regex :2 cents:

2012 06-26-2009 02:33 AM

Quote:

Originally Posted by quantum-x (Post 16001197)
That's a terrible regex :2 cents:


fallenmuffin 06-26-2009 02:35 AM

Quote:

Originally Posted by quantum-x (Post 16001197)
That's a terrible regex :2 cents:

So, offer him a better one. It's one I grabbed off StackFlow.

2012 06-26-2009 02:35 AM

Quote:

Originally Posted by fallenmuffin (Post 16001213)
So, offer him a better one. It's one I grabbed off StackFlow.

werd :2 cents: let's help each other fuckin shit fuck ...

2012 06-26-2009 02:55 AM

I mean, It's such a forgiving environment ... why wouldn't you pull some bullshit code and pisson'em like that.

It's a great place for friends and shit. Cool, yeah

2012 06-26-2009 03:51 AM

Quote:

Originally Posted by quantum-x (Post 16001197)
That's a terrible regex :2 cents:

:upsidedow

fris 06-26-2009 06:08 AM

Code:

^<a[^>]*(http://[^"]*)[^>]*>([ 0-9a-zA-Z]+)</a>$

quantum-x 06-26-2009 06:55 AM

I was passing through at 4:30AM - just felt obligated to point out that the regex posted was very weak.

Now, the regex posted by fris is a hell of a lot better - it actually copes with real world scenarios.

I'm sorry if you don't like me pointing out what strikes me as non-optimised code. Rubbing each other's nuts helps noone ;)

tranza 06-26-2009 06:58 AM

Bump for php coders

Iron Fist 06-26-2009 07:57 AM

Quote:

Originally Posted by quantum-x (Post 16001803)
Rubbing each other's nuts helps noone ;)

It does feel really good however. :2 cents:

quantum-x 06-26-2009 08:14 AM

Quote:

Originally Posted by sharphead (Post 16002008)
It does feel really good however. :2 cents:

Little lower please :winkwink:

ExLust 06-26-2009 08:17 AM

Mmmm... interesting!

gornyhuy 06-26-2009 08:17 AM

regex gives me heartburn and I only fuck with it while on the clock. :)

sheepish 06-26-2009 10:39 AM

Thanks Fris - it worked a treat and is much appreciated. And thanks for all for helping out (even FartFly!)

M.

fris 06-26-2009 11:09 AM

Quote:

Originally Posted by sheepish (Post 16002551)
Thanks Fris - it worked a treat and is much appreciated. And thanks for all for helping out (even FartFly!)

M.

No problem


All times are GMT -7. The time now is 10:09 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123