WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP help, Assign class to photo from specific url source? (7 posts)

  1. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    OK, I have no idea if this is possible, with php, or with anything....

    I've got an autopost service set up through posterous so I can post by email when I'm away from computers.

    Normally I upload my own photos, and everything aligns great.

    When I upload through posterous, they host the photo and automatically post it to my WP site. Which is very cool, but they don't allow control of photo size at all, and they don't assign anything that I can use to control the photo.

    The photos from the service are simply <img> inside of <p> in my content class. So if I try to apply styling to those photos, I can't get specific enough, it affects all sorts of other things from various plugins that insert images.

    Now, on to my question.

    All the photos posted by posterous come from a similar url

    img src="http://posterous.com/getfile/files.posterous.com/rvoodoo/LVNlptGCNES5Z/CIMG0001.jpg.scaled.500.jpg" width="500" height="668"/>

    the first part of the url is always the same, the last random stuff changes per picture

    Is there something I can do to assign a class to the photos based on the first static portion of the url? Or does anyone have a better idea?

    I'm contacting the service to see if they can add classes in an upgrade, but I'd love to figure something out now, on my end.

    Thanks peeps!

  2. Mark / t31os
    Moderator
    Posted 4 years ago #

    You could use a CSS selector, but it'll only work for the more modern versions of the browsers...

    img[src^="http://posterous.com/getfile/files.posterous.com/rvoodoo/"]

    Would match any image that has a src starting with the above..

    Some selector examples:

    /* Starts with */
    [attribute^=""]
    /* Ends with */
    [attribute$=""]
    /* Contains */
    [attribute*=""]
  3. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    oh no sh$%?

    cool....I'll have to mess around with that a bit, Thanks!

    edit-that sure did work.....cleaned my page back up, thanks for sure!

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    You're welcome.. ;)

  5. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    I'll mark this resolved....solution works good enough for me

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    well, I got this resolved quite nicely! The folks over at posterous started assigning a class <div class="posterous_autopost"> to wrap all content they send out to WP. Very nice fix for me, and everyone really!

  7. Mark / t31os
    Moderator
    Posted 4 years ago #

    Good stuff.. :)

Topic Closed

This topic has been closed to new replies.

About this Topic