WordPress.org

Ready to get started?Download WordPress

Forums

Replace URL with Image (7 posts)

  1. c6ke
    Member
    Posted 1 year ago #

    Hey there!
    I'm trying to find a way to do the following:
    - User posts an URL to an Image on my hosted WP as a comment
    - WordPress shows The URL, not the image itself

    Now, is there any way I can teach WordPress to replace that URL with the image itself (I don't even need width and height as those are determined by CSS max-width and -height) and Yes: I can trust my users ;)
    It should work in Posts and Comments, ideally.

    So basically don't show URLs but Images themselves. It works with Vimeo-URLs, Youtube-URLs and so on, but not with GIF, JPG...... if they come from URLS.

    Thanks in advance for your help! I undestand average coding (CSS, Theme-Edit and a slice of PHP) ;)

  2. tomontoast
    Member
    Posted 1 year ago #

    You can do a regular expression replace on comment_content or post content using a filter.

  3. tomontoast
    Member
    Posted 1 year ago #

  4. tomontoast
    Member
    Posted 1 year ago #

  5. c6ke
    Member
    Posted 1 year ago #

    That is a great start. - THANKS!
    Wordpress already changes The URL-Texts to clickable ones (inserting anchor-tags A). Do you possibly know where it does that? In that case I'd only have to add that one IF-ELSE-Statement from stackoverflow ;)

  6. tomontoast
    Member
    Posted 1 year ago #

  7. c6ke
    Member
    Posted 1 year ago #

    That Plugin still works and just inserts BBCodes - which is fine with my users. Thank you very much!
    Perhaps I'll care about the filter replacement soon but so far: This is great!
    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic