Reputation: 1
Hey I have a trolling problem at my forum.
Long story short:
There is a troll who comes and posts images from a number of gore sites. In fact this person hotlinks them directly from the source. For obvious reasons, I want to put this to an end.
I was thinking of implementing a code that does the following:
- Checks the source of an image before allowing it to load.
- If the src of the image is a url that contains the word 'gore', the image is NOT displayed.
While I realize this isn't a permanent solution, I think this is a step in the right direction. Thoughts? Any idea how I can get started?
JQuery is really a foreign "language" to me but it seems like that's what I need.
In the code below c_post
stands for the actual post, meaning this code targets only images posted inside posts. What I want the code to do is select for the word 'gore'.
$('c_post img[src*="gore"]').attr({ hide(); })
Upvotes: 0
Views: 45
Reputation: 11
I believe you can accomplish this with a RegEx check
if ( $('c_post img').attr('src').match(/gore/) ) {
$('c_post img').attr("src", "filteredimage")
}
If the image's src attribute matches the RegExp, you'd be able rewrite the src url to a specific image of your choice.
or, if you just want to hide it you could instead do the following inside the if statement:
$('c_post img').css("display", "none")
Upvotes: 1