BBcode IMG add width height

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Scam Warning
irishmike
Registered User
Posts: 2
Joined: Mon Sep 27, 2010 8:47 pm

BBcode IMG add width height

Post by irishmike » Mon Sep 27, 2010 8:51 pm

Basically, here is what I would like.

turn this

Code: Select all

[img width=500 height=500]image url[/img]
into this

Code: Select all

<img src="image url"  width="500px" height="500px" />
Also to not error out if just one of the values is entered.

I don't need any new buttons, just the option to do this will suffice. I found some of the mods that will do this, but they are all really complicated. I don't want to have to edit 20 php pages, just the bbcode php.

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: BBcode IMG add width height

Post by Tom » Mon Sep 27, 2010 9:23 pm

If you don't want to MOD a lot of files, then why not just add a new custom BBCode through the ACP? Below are the specifications for a custom BBCode I just created with the tags [fimg][/fimg] ("img" with an "f" in front of it for "flexible"). Just navigate to the Custom BBCodes section of the ACP and create a new BBCode with the following information:

BBCode usage

Code: Select all

[fimg={NUMBER1},{NUMBER2}]{URL}[/fimg]
HTML replacement

Code: Select all

<img src="{URL}" style="width: {NUMBER1}px;height: {NUMBER2}px;" />
Help line

Code: Select all

Image with specified dimensions: [fimg=width,height]ImageURL[/fimg]
This BBCode will be separate from the default [img] BBCode, but it will allow an image to be embedded in a post using the HTML <img> tag and will allow a user to specify a width and height in which the image will be displayed in the post.

Here is an example of how to include a random image and set it to display with a width of 400px and a height of 150px:

Code: Select all

[fimg=400,150]http://www.mysite.com/my_image.jpg[/fimg]
As you can see, you start off with an [fimg= tag and then specify the desired width of the image, then place a comma and afterward specify the desired height of the image. That will then display the image in the post at the width and height specified. And only use this custom BBCode to embed images that you want to change the dimensions of. If you want the original dimensions of the image to be maintained in the post, then just use the [img] tag as usual.

While this is a separate BBCode from the default [img] tag, at least it can be done without requiring any file edits. ;)
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

irishmike
Registered User
Posts: 2
Joined: Mon Sep 27, 2010 8:47 pm

Re: BBcode IMG add width height

Post by irishmike » Mon Sep 27, 2010 10:11 pm

I feel stupid. I totally didn't see the custome bbcode section. I thought it had to be hard coded. Thanks!

sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: BBcode IMG add width height

Post by sebastos.pl » Sat Nov 05, 2011 9:03 pm

Tom wrote:While this is a separate BBCode from the default [img] tag, at least it can be done without requiring any file edits. ;)
I want this in [img] tag. What files i must edit?

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: BBcode IMG add width height

Post by Jessica » Sun Nov 06, 2011 4:31 pm

sebastos.pl wrote:
Tom wrote:While this is a separate BBCode from the default [img] tag, at least it can be done without requiring any file edits. ;)
I want this in [img] tag. What files i must edit?
just add the custom bbcode.....
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: BBcode IMG add width height

Post by sebastos.pl » Sun Nov 06, 2011 10:02 pm

:?:
When I wrote:

[img={NUMBER1},{NUMBER2}]{URL}[/img]

<img src="{URL}" style="width: {NUMBER1}px;height: {NUMBER2}px;" />

I saw:
"The BBCode tag name that you selected already exists."

User avatar
Jessica
Former Team Member
Posts: 4342
Joined: Sun Jul 18, 2010 2:53 pm
Location: Pennsylvania, USA
Name: Jessica
Contact:

Re: BBcode IMG add width height

Post by Jessica » Mon Nov 07, 2011 2:08 am

I think it's because of the regular [img] tag. you'll wait to make it [img1] and [/img1] or something so it doesn't have the same beginning and ending tag as the [img]
Pro-choice, Atheist, Pro-LGBT rights
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. - Albert Einstein

User avatar
Sniper_E
Registered User
Posts: 783
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: BBcode IMG add width height

Post by Sniper_E » Mon Nov 07, 2011 5:54 am

You could also use [image= or anything else. Setting just a width might be a thought, without the height.
Using just a width, the height will be proportional to the actual image size.
Visa versa too if you used just the height.

Like this with one number for the width...

Code: Select all

[image={NUMBER}]{URL}[/image]
And if you had highslide installed you could even use it's classes in your html replacement.

Code: Select all

<a href="{URL}" class="highslide" onclick="return hs.expand(this)"><img src="{URL}" width="{NUMBER}"  alt="" /></a>
Then by linking to a large image and selecting 200px for it's width in your post...

Code: Select all

[image=200]http://somesite.com/images/very_large_image.png[/image]
The image will be 200px wide in your page and popup with a large highslide view when clicked.
Just an additional option...
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: BBcode IMG add width height

Post by sebastos.pl » Mon Nov 07, 2011 7:58 am

Jessica wrote:I think it's because of the regular [img] tag. you'll wait to make it [img1] and [/img1] or something so it doesn't have the same beginning and ending tag as the [img]
I converted forum from myBB, so I have a lot [img=400x400] and similiar...

Is it possible that it was in a tag [img]?

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: BBcode IMG add width height

Post by 4_seven » Mon Nov 07, 2011 6:45 pm

you can try this snippet, which can transform most standard bbcodes
http://www.4seven.de/forum/6test/viewtopic.php?f=6&t=90
Current Mods | Mod Base | php(BB) programming | No help via PM

sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: BBcode IMG add width height

Post by sebastos.pl » Thu Nov 10, 2011 10:05 pm

Could you write instructions?... Please.

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: BBcode IMG add width height

Post by 4_seven » Thu Nov 10, 2011 10:41 pm

there is a instruction..
Current Mods | Mod Base | php(BB) programming | No help via PM

sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: BBcode IMG add width height

Post by sebastos.pl » Thu Nov 10, 2011 10:44 pm

about ""... :(

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: BBcode IMG add width height

Post by 4_seven » Thu Nov 10, 2011 10:45 pm

so just transform the instruction to [img]

it's case 4: in bbcode.php

and make your bbcode after doing that ;)

Code: Select all

[img={NUMBER1},{NUMBER2}]{URL}[/img]

<img src="{URL}" style="width: {NUMBER1}px;height: {NUMBER2}px;" />
Last edited by 4_seven on Thu Nov 10, 2011 10:48 pm, edited 1 time in total.
Current Mods | Mod Base | php(BB) programming | No help via PM

sebastos.pl
Registered User
Posts: 39
Joined: Wed Sep 21, 2011 9:46 pm

Re: BBcode IMG add width height

Post by sebastos.pl » Thu Nov 10, 2011 10:48 pm

after this modification standard bbcode:
[img]{URL}[/img]
still work?

Locked

Return to “[3.0.x] MOD Requests”