PHP guys - help, please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sheepish
    Confirmed User
    • Jun 2002
    • 48

    #1

    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
    Confirmed User
    • Nov 2005
    • 8170

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

    Comment

    • 2012
      So Fucking What
      • Jul 2006
      • 17189

      #3
      so you want us to help you remove all the "link codes" in your images ... neat
      best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

      Comment

      • 2012
        So Fucking What
        • Jul 2006
        • 17189

        #4
        best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

        Comment

        • sheepish
          Confirmed User
          • Jun 2002
          • 48

          #5
          Originally posted by fartfly
          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.

          Comment

          • quantum-x
            Confirmed User
            • Feb 2002
            • 6863

            #6
            Originally posted by fallenmuffin
            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
            PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

            Comment

            • 2012
              So Fucking What
              • Jul 2006
              • 17189

              #7
              Originally posted by quantum-x
              That's a terrible regex
              best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

              Comment

              • fallenmuffin
                Confirmed User
                • Nov 2005
                • 8170

                #8
                Originally posted by quantum-x
                That's a terrible regex
                So, offer him a better one. It's one I grabbed off StackFlow.

                Comment

                • 2012
                  So Fucking What
                  • Jul 2006
                  • 17189

                  #9
                  Originally posted by fallenmuffin
                  So, offer him a better one. It's one I grabbed off StackFlow.
                  werd let's help each other fuckin shit fuck ...
                  Last edited by 2012; 06-26-2009, 01:38 AM.
                  best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

                  Comment

                  • 2012
                    So Fucking What
                    • Jul 2006
                    • 17189

                    #10
                    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
                    best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

                    Comment

                    • 2012
                      So Fucking What
                      • Jul 2006
                      • 17189

                      #11
                      Originally posted by quantum-x
                      That's a terrible regex
                      best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

                      Comment

                      • fris
                        I have to go potty
                        • Aug 2002
                        • 55795

                        #12
                        Code:
                        ^<a[^>]*(http://[^"]*)[^>]*>([ 0-9a-zA-Z]+)</a>$
                        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                        My Newest Theme

                        Comment

                        • quantum-x
                          Confirmed User
                          • Feb 2002
                          • 6863

                          #13
                          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 ;)
                          PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                          Comment

                          • tranza
                            ICQ: 197-556-237
                            • Jun 2003
                            • 57559

                            #14
                            Bump for php coders
                            I'm just a newbie.

                            Comment

                            • Iron Fist
                              Too lazy to set a custom title
                              • Dec 2006
                              • 23400

                              #15
                              Originally posted by quantum-x
                              Rubbing each other's nuts helps noone ;)
                              It does feel really good however.
                              i like waffles

                              Comment

                              • quantum-x
                                Confirmed User
                                • Feb 2002
                                • 6863

                                #16
                                Originally posted by sharphead
                                It does feel really good however.
                                Little lower please
                                PrettyInCash.com - BoozedGFs.com - TeenGFs.com - JizzGFs.com- MilfUploads.com -

                                Comment

                                • ExLust
                                  Confirmed User
                                  • Aug 2008
                                  • 3223

                                  #17
                                  Mmmm... interesting!

                                  BE A PARTNER

                                  Comment

                                  • gornyhuy
                                    Chafed.
                                    • May 2002
                                    • 18041

                                    #18
                                    regex gives me heartburn and I only fuck with it while on the clock.

                                    icq:159548293

                                    Comment

                                    • sheepish
                                      Confirmed User
                                      • Jun 2002
                                      • 48

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

                                      M.

                                      Comment

                                      • fris
                                        I have to go potty
                                        • Aug 2002
                                        • 55795

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

                                        M.
                                        No problem
                                        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                                        My Newest Theme

                                        Comment

                                        Working...