Announcement

Collapse
No announcement yet.

Converting image tags [img=url] to [img]url[/img]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting image tags [img=url] to [img]url[/img]

    From reading, sounds like cleaner.php is my best solution, but what exactly is the regular expression that I need to run inside of cleaner to conver [img=urlGoesHere] to [img]urlGoesHere[/img]

    Thanks!

  • #2
    This should help, the img regex there should do what you're after :

    http://www.vbulletin.com/forum/showthread.php?t=282129
    I wrote ImpEx.

    Blog | Me

    Comment


    • #3
      Originally posted by Jerry View Post
      This should help, the img regex there should do what you're after :

      http://www.vbulletin.com/forum/showthread.php?t=282129
      That doesn't quite get what I needed.

      The url of the image is INSIDE the [img=] so it looks like [img=http://imagepathhere]

      I need to grab that image path and put it into regular [img][/img] tags.

      -Tom

      Comment


      • #4
        Originally posted by trhoppe View Post
        That doesn't quite get what I needed.

        The url of the image is INSIDE the [img=] so it looks like [img=http://imagepathhere]

        I need to grab that image path and put it into regular [img][/img] tags.

        -Tom
        Try that. Back up ur data first XD

        PHP Code:
        $text preg_replace('#\[img=(.*)\]#siU''[img]$1[/img]' ,$text); 

        Comment


        • #5
          Which would be :

          PHP Code:
          $text preg_replace('#\[img=(.*)\](.*)\[/img]#siU''[img]$1[/img]'$text); 
          I wrote ImpEx.

          Blog | Me

          Comment


          • #6
            Originally posted by dave683 View Post
            Try that. Back up ur data first XD

            PHP Code:
            $text preg_replace('#\[img=(.*)\]#siU''[img]$1[/img]' ,$text); 
            Close, though that won't clean out what is in between the tags and match-to-replace the origional closing one.
            I wrote ImpEx.

            Blog | Me

            Comment


            • #7
              Originally posted by Jerry View Post
              Close, though that won't clean out what is in between the tags and match-to-replace the origional closing one.
              Actually $text = preg_replace('#\[img=(.*)\]#siU', '[img]$1[/img]', $text); was it

              I now understand a bit more about reg exps but I still have no idea what "$1" is in the replacement and how that works.

              The other one which had preg_replace('#\[img=(.*)\](.*)\[/img]#siU' never matched as the dumb megaBBS board never had closing img tags.

              Jerry, thanks for all the help with the import, this thread and the others that you answered had great advice and help!

              dave683, thanks for the help with that statement

              -Tom

              Comment


              • #8
                Ah yes, my bad, I didn't read it fully and missed that there was no closing [/img] tag ..... !
                I wrote ImpEx.

                Blog | Me

                Comment


                • #9

                  .
                  .
                  .

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...
                  X