SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Zealot Zurev's Avatar
    Join Date
    Feb 2009
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Add html attributes to a tag via PHP

    I was wondering if there was a way to do this rather than make my own function, I have a tag like

    PHP Code:
    <img src="image.jpg"
    and I need to add attributes to it, sometimes more than one, like height=x and width=x sometimes, but not others.

    So a tag in that format is stored in my database column, and I need to modify them on the fly, any ideas?

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does this work for you?
    http://www.php.net/manual/en/domdocu...eattribute.php

    See domdocument library and its examples in user notes.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    SitePoint Zealot Zurev's Avatar
    Join Date
    Feb 2009
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rajug View Post
    Does this work for you?
    http://www.php.net/manual/en/domdocu...eattribute.php

    See domdocument library and its examples in user notes.
    Is that much necessary? I'm not looking to create a new document or anything, simply take an image tag and add a few attributes, thought it seemed more like string manipulation.

  4. #4
    SitePoint Zealot Zurev's Avatar
    Join Date
    Feb 2009
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On second thought, I just decided to delete all records and change up how I store the image url, storing it as a plain url so I can later format it however I want it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •