MyBB Community Forums

Full Version: Show posts with images Only
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Lets take an example of a very large thread dedicated to images but of course this thread would have hundereds of posts with no images So is there a way that an option display beneath every thread i.e "show posts with images only" image can either be attachments or embeded
Anyone can help me with this???
This would be rather difficult to accomplish for embedded images.
I think embedded images wouldn't be that bad. Just use the like operator.

$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "posts WHERE (message LIKE '%.png%' OR message LIKE '%.gif%' OR message LIKE '%.jpg%') AND tid=$tid");

// Could otherwise try something like this:
$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "posts WHERE message LIKE '%[img]%[/img]%' AND tid=$tid");

// Another option with using Regex:

$regex = "\[img\](.*)\.(png|gif|jpg)\[\/img\]";
$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "posts REGEX '" . $regex . "' AND tid=$tid");
(2014-06-24, 02:49 PM)dragonexpert Wrote: [ -> ]I think embedded images wouldn't be that bad. Just use the like operator.

$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "posts WHERE (message LIKE '%.png%' OR message LIKE '%.gif%' OR message LIKE '%.jpg%') AND tid=$tid");

// Could otherwise try something like this:
$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "posts WHERE message LIKE '%[img]%[/img]%' AND tid=$tid");

// Another option with using Regex:

$regex = "\[img\](.*)\.(png|gif|jpg)\[\/img\]";
$query = $db->query("SELECT * FROM " . TABLE_PREFIX . "posts REGEX '" . $regex . "' AND tid=$tid");

Wow this is what I was looking for however this will also collect posts with smilies right? though we can identify smilies through URL
how can I filter smilies using Regex???

smilies
images/smilies/xyz.gif
other images
http://xyz.com/fdsfsd/dfsfsdfs/sdfsf/rt.gif
The second query shouldn't grab smilies since it relies on img tags.
None should bring smilies unless you use something like :-).png which I doubt. Also, try using the simple_select() method instead of query().
(2014-06-26, 12:55 PM)dragonexpert Wrote: [ -> ]The second query shouldn't grab smilies since it relies on img tags.

BUt In database smilies and images both are being saved with img tag

(pls correct me if I'm wrong)
this is what I see in table mybb_posts
[img]images/smilies/heart.gif[/img]
(2014-06-26, 02:17 PM)Omar G. Wrote: [ -> ]None should bring smilies unless you use something like :-).png which I doubt. Also, try using the simple_select() method instead of query().

I normally do, but was just in a hurry. The third query though you absolutely cannot use simple_select since if anything is in the third parameter it adds WHERE which would be invalid.

If they are using an url that results in a smiley, there is nothing else that can be done about it.
(2014-06-26, 03:24 PM)burraak Wrote: [ -> ](pls correct me if I'm wrong)
this is what I see in table mybb_posts
[img]images/smilies/heart.gif[/img]

I don't think this is how it works. If your forum works like this then probably you should rethink the way you implement your smilies.