referencing thumbnail width

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

referencing thumbnail width

Post by shortmort37 » Tue Jan 31, 2017 3:08 pm

Can someone tell this novice how you would reference ACP -> attachment settings -> thumbnail width from content.css, and from attachment.html?

Thanks
Dan
Last edited by bonelifer on Tue Jan 31, 2017 4:38 pm, edited 1 time in total.
Reason: Moved from phpBB Discussion

User avatar
Lumpy Burgertushie
Registered User
Posts: 62930
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: referencing thumbnail width

Post by Lumpy Burgertushie » Tue Jan 31, 2017 3:41 pm

what does that mean? what are you trying to do?


robert
I am available for custom work on a donation basis. Please send me a PM with your needs.
Premium phpBB 3.2 Styles by PlanetStyles.net

New phpbb 3.0 support site

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Tue Jan 31, 2017 3:55 pm

I'm returning to an earlier attempt to make a gallery style for attachments. For thumbnails whose width is fixed statically on upload, I'd like to match their display width in content.css with the ACP definition. For videos in attachment.html, I'd like to dynamically set the video width to the same.

Dan

User avatar
canonknipser
Registered User
Posts: 827
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: referencing thumbnail width

Post by canonknipser » Tue Jan 31, 2017 4:04 pm

There should be a value in the config-table having "thumb" in the name, so just look with SELECT * FROM phpbb_config WHERE config_name like '%thumb%' in your DB, and then use $config['your_config_name'] in your script.
Greetings
Frank
phpbb.de support team member
English is not my native language
New arrival - Extensions and scripts for phpBB
no support via PM or mail

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Tue Jan 31, 2017 6:32 pm

Thanks Frank! I will check that out. That will work for templating in attachment.html - what about in content.css? (And thanks for your earlier script for resizing thumbnails - I'll be using that when I deploy my gallery.)

Dan

User avatar
canonknipser
Registered User
Posts: 827
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: referencing thumbnail width

Post by canonknipser » Tue Jan 31, 2017 7:57 pm

For content.css - won't work because it is not "templated".
But you can define the main parts of the class in content.css and overwrite the width and height from your template. There you can use template variables set by your script - it is already done eg. for flash files <object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="{_file.WIDTH}" height="{_file.HEIGHT}">

Glad you find my little script useful ;)
Greetings
Frank
phpbb.de support team member
English is not my native language
New arrival - Extensions and scripts for phpBB
no support via PM or mail

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Tue Jan 31, 2017 8:08 pm

Many thanks!

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Mon Feb 13, 2017 9:24 pm

Hi Frank,

Returning to this topic again.
canonknipser wrote:
Tue Jan 31, 2017 4:04 pm
There should be a value in the config-table having "thumb" in the name, so just look with SELECT * FROM phpbb_config WHERE config_name like '%thumb%' in your DB, and then use $config['your_config_name'] in your script.
Yup, that worked - the name is img_max_thumb_width. However, I have to reference it via templating somehow, no? It's in attachment.html. I want to dynamically constrain the width of an mp4 video based on its value (I've modified attachment.html to play mp3/mp4's natively in an HTML5 browser) - which, is different than _file.WIDTH.

Thanks
Dan

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Tue Feb 14, 2017 12:00 am

Hmmm... From this reference, it looks like I need to do:

$template->assign_var('S_THUMB_WIDTH', $config['img_max_thumb_width']);

And then I can use it in my mod'ed attachment.html like so: <video width="{S_THUMB_WIDTH}" height="auto" controls name="media">

That is, unless the maximum thumb width is already defined somewhere as a template variable (although, I couldn't find it). Am I correct about this approach?

If so, what is the proper PHP Controller file where I should assign the variable? (It looks like attachment.html is referenced in functions_content.php, so I'm guessing that's the file.) And is "$template" above a generic name, for which I should substitute some other name?

Thanks
Dan

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Fri Feb 24, 2017 9:32 pm

OK - I was able to assign the variable for thumbnail width I created in functions_content.php, and pass it to attachments.html. And it constrains the width of video, just as I had hoped.

However, I created "figure" and "figcaption" in content.css, to permit thumbnails to float in a gallery style, and to attach a caption to them. In "figcaption", if I set "width: 350px" in content.css, I can constrain the width of the caption block to that of the thumbnail, and text wraps. However, if I want to make it respect the thumbnail width set in the ACP, and pass it to attachment html like so: <figcaption width="{_file.S_MAX_THUMB_WIDTH}"> , it doesn't exhibit the same behavior. The border around the thumb and the caption expands to contain the caption. Here's an example:

http://www.59plymouth.net/59test/viewto ... f=3&t=2921

Any ideas? I can hard-code content.css, but I was hoping to avoid that.

Dan

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Sun Mar 19, 2017 10:29 pm

canonknipser wrote:
Tue Jan 31, 2017 7:57 pm
Glad you find my little script useful ;)
Hi Frank - useful indeed! I see elsewhere that you have contributed to an extension that presents jpeg EXIF data. Most browsers have the ability to respect orientation when presenting the full size image - but, is there a parameter I can supply to ImageMagick in your script, to have it generate the thumbnail in the proper orientation?

adTHANKSvance
Dan

User avatar
shortmort37
Registered User
Posts: 328
Joined: Sat Aug 26, 2006 8:40 pm

Re: referencing thumbnail width

Post by shortmort37 » Sun Mar 19, 2017 10:34 pm

Hmmm... Perhaps I should RTFM :roll:

It looks like -auto-orient is what I need to add. Thanks again for a lovely script!

Dan

User avatar
canonknipser
Registered User
Posts: 827
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: referencing thumbnail width

Post by canonknipser » Mon Mar 20, 2017 11:48 am

Hi Dan, sorry for the late respond, somehow I missed your last posts.
I'm not sure if your figured out by yourself in the meantime.

For your css questions, I'm not a designer and my css knowledge is very, very basic, so I'm the wrong person for that.

But as a global statement:
Did you create your own style as a inherited style or do you modify the original file? Keep in mind when working with the original, you must redo all edits after phpBB-Updates.

And for modifying the php-file: better to create a extension which creates and injects the new variables to the template (my extension does pretty much the same)

shortmort37 wrote:
Tue Feb 14, 2017 12:00 am
what is the proper PHP Controller file where I should assign the variable?
I use core.parse_attachments_modify_template_data as you can see here: https://github.com/canonknipser/viewexi ... er.php#L26

Maybe it is also a option for you to use your own template by using template events in attachment.html instead of modifying the original one.
Idea (untestet):

Put your own code in shortmort_attachment.html and create a template switch S_SHORTMORT_ENABLED in your extension (true when you want to send out "your" code, false when you want to use the original attachments)

create two files in your extension
attachment_file_before.html

Code: Select all

<!--- IF S_SHORTMORT_ENABLED -->
<!-- INCLUDE shortmort_attachment.html -->
<!-- ELSE -->
attachment_file_after.html

Code: Select all

<!-- ENDIF -->
shortmort37 wrote:
Sun Mar 19, 2017 10:29 pm
Most browsers have the ability to respect orientation when presenting the full size image - but, is there a parameter I can supply to ImageMagick in your script, to have it generate the thumbnail in the proper orientation?
Normally, during upload via plupload the images shout be rotated automatically; and the generated thumbnail should work on a already rotated images, so no need to rotate again for the thumbnail. But some images (esp. from mobiles) often have wrong orientation flags.
shortmort37 wrote:
Sun Mar 19, 2017 10:34 pm
RTFM
O yes, that helped me a lot the last 30 years ... :roll:
Greetings
Frank
phpbb.de support team member
English is not my native language
New arrival - Extensions and scripts for phpBB
no support via PM or mail

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: andreask, Crizzo, DevMakoto and 6 guests