Maximum Images Per Post

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670
Maximum Images Per Post
« on November 24th, 2012, 11:53 AM »Last edited on November 24th, 2012, 11:47 PM
This is a very simple plugin that bakes cheesecake and apple pie. [1] Actually, it extends the new Moderation filters to be able to limit the number of images embedded within a post. This could be probably done with a complex regex and without the need of a plugin, but that requires more skill than I currently have. Plus it's more user friendly this way. Plus now we have a plugin made that expands this lonely area.. Plus it's after three. Plus I should be  in bed. Plus... hey, don't throw that plate at me!

I got this idea when I saw a support topic at SM asking about such, and was bewildered when the truth was revealed[2].

Implementing this was dead easy. Three lang strings, a template (yes, one sub-block), one hook. Took more time to research (!) this than  to actually write it up!
 1. Oh, I'm thinking about food  again, aren't I,,, hope everyone had a great Thanksgiving!
 2. No such facility exists!
A confident man keeps quiet.whereas a frightened man keeps talking, hiding his fear.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Maximum Images Per Post
« Reply #1, on November 24th, 2012, 12:52 PM »
Sweet, the moderation filters can be extended through the hooks! (Not tested, you see)

I still haven't figured out how to cope with making a nicer error message to users, though. I might just give them a space to add an explanation for the users rather than trying to write something that makes a sensible explanation out of the rules given how complex rules can actually be.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Maximum Images Per Post
« Reply #4, on December 5th, 2012, 04:22 AM »
Just a random thought, instead of doing a preg_replace first, couldn't you just:
Code: [Select]
return substr_count(strtolower($body), '[img');

(Yes, I looked at your max images plugin as the base for Word Count Limits. Made me realise how messed up the API is.)

live627

  • Should five per cent appear too small / Be thankful I don't take it all / 'Cause I'm the taxman, yeah I'm the taxman
  • Posts: 1,670

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Maximum Images Per Post
« Reply #6, on December 6th, 2012, 07:02 AM »
What do you mean? It's looking for any img tag openers, not complete img tags...