Donations

Help support Pro_News and become a member of our Sponsors Group
The tip jar is at PayPal, but does not require a PayPal account
User Info
Wilkommen Unbekannt
Mitglieder:
Neuestes: Witewolf
Heute neu: 0
Gestern neu: 0
Gesamt: 151
Anwesende Nutzer:
Mitglieder: 0
Besucher: 41
Roboter: 4
Gesamt: 45
Wer ist wo?:
Besucher:Support Forums
Support Forums
Pro News Articles
Support Forums
Nedladdningar
Pro News Articles
Support Forums
Support Forums
Support Forums
Pro News Articles
Support Forums
Support Forums
Pro News Articles
My Account
Nedlastninger
Pro News Articles
Support Forums
Pro News Articles
Support Forums
Nedladdningar
Pro News Articles
Pro News Articles
Pro News Articles
Pro News Articles
Pro News Articles
Support Forums
Support Forums
Pro News Articles
Support Forums
Téléchargement
Support Forums
Support Forums
Support Forums
Support Forums
Support Forums
Pro News Articles
Support Forums
Pro News Articles
Pro News Articles
Downloads
Support Forums
Roboter:Google > Pro News Articles
Baidu > Pro News Articles
Voila > Support Forums
YANDEX > Téléchargement
Wer ist online:
Keine Mitglieder online!
Resizeable IMG function in BBCode
Resizeable IMG function in BBCode
Verfasst am: Sun Oct 24, 2010 8:28 pm
A few peeps have been asking for better image handling in Pro_News, but I figured at least some of this extra flexibility belongs in Dragonfly in general, not just in Pro_News.
So I've attached a very simple hack of BBCode which will add on-the-fly image resizing to the [img] BBCode wherever it is used, using the syntax img w=# h=#.
In /includes/nbbcode.php find the lines
$patterns[] = "#\[img\]([\w]+(://|\.|/)[^ \?&=(\"\n\r\t<]*?)\[/img\]#si";
$replacements[] = "<img src=\"\\1\" style=\"border:0;\" alt=\"\" />";
and replace with these 2 lines
EDIT: THIS FIX FAILS IN IE8 - Use new version posted below (2 posts down)
$patterns[] = "#\[(?:img|img (?:w|width)=([0-9]{1,3}) (?:h|height)=([0-9]{1,3}))\]([\w]+(://|\.|/)[^ \?&=(\"\n\r\t<]*?)\[/***\]#si"; // layingback img w=# h=#
$replacements[] = "<img src=\"\\3\" width=\"\\1\" height=\"\\2\" style=\"border:0;\" alt=\"\" />"; // layingback img w=# h=# where '***' MUST be replaced by the letters 'img' (I had to substitute to be able to display at all in BBCode).
That's the change, but to bring the Help line into sync, look in /language/{your_language}/bbcode.php to find the line
'img' => array(_IMAGE.':','[img]http://image path[/img]'),
and change to
'img' => array(_IMAGE.':','[img]http://image path[/img] to resize: [img w=# h=#]'), // or [img width=# height=#] - layingback
The supported syntax is img as before, or img w=### h=###, where ### is any number between 1 and 999, and specifies the width="" and height="" values to be used in the generated HTML. In addition the syntax img width=### height=### is also supported for consistency with other (non-DF) BBCode hacks.
There you go, image resizing! If you find a use for this, please consider a donation to my hosting costs. TIA! It looks simple, but no-one else has come forward with one in 6 years! ![]()
Hopefully this will be followed soon by a fully flexible image inset function in Pro_News, but in the meantime you can resize any image in Pro_News, News, Forums, etc.
Note that the above is for standard DF and Pro_News, but it should be straightforward to apply this hack to ForumsPro and/or EHP's NBBCode module as the affected lines of code are essentially the same.
Finally note that image resizing is not a total panacea for all cases - a large image down-sized will still incur a large download bandwidth penalty, but sometimes a resize is just unavoidable.
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1
Zuletzt bearbeitet von layingback am Sun Feb 13, 2011 12:18 pm, insgesamt einmal bearbeitet

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resizeable IMG function in BBCode
Verfasst am: Thu Feb 10, 2011 8:29 pm
Have just tried adding an image to an article, not specifying any width or height and the image didn't display. Looking at the source the image is shown as width="" height="" which is presumably why it won't display. This is with IE8. How can I avoid that?
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Re: Resizeable IMG function in BBCode
Verfasst am: Fri Feb 11, 2011 12:05 am
Rewrite the hack?
A quick Google indicates that IE8 will assume width and height of 1px if width and height are not given. Rather than defaulting to found image size. Grrrrrh!
OK, can you try this please? Looks as if it might work - please check on all browsers that you have.
Use this for the replacement code in nbbcode.php:
$patterns[] = "#\[(?:img|img (?:w|width)=([0-9]{1,3}) (?:h|height)=([0-9]{1,3}))\]([\w]+(://|\.|/)[^ \?&=(\"\n\r\t<]*?)\[/img\]#sie"; // layingback img w=# h=#
$replacements[] = "'<img src=\"\\3\"'.('\\1' == '' ? '' : ' width=\"\\1\" height=\"\\2\"').' style=\"border:0;\" alt=\"\" />'"; // layingback img w=# h=#
This will drop the resizing entirely if a width is not specified.
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Beiträge: 1229
- Dabei seit: Mar 18, 2006
Re: Resizeable IMG function in BBCode
Verfasst am: Sun Feb 13, 2011 11:58 am
Seems to work, thank you (and damn that IE, I know!)
rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/4.1.22/5.2.17/9.3.3.1

rosbif- BetaTester

- Beiträge: 492
- Dabei seit: Aug 01, 2007
- Wohnort: Chantilly, France
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst keine Dateien anhängen.
Du kannst Dateien herunterladen.
Alle Zeitangaben sind in GMT











