Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#145 2011-04-02 02:10:11

wolfcry911
Member
From: MA, USA
Registered: 2006-06-30
Posts: 51

Re: smd_random_banner: Random banner image for advertising

Hi Bloke,
First, thank-you very much for all your work!!

I have a request for this plugin. Could height and width attributes be added so as to override the value stored in the database. And specifically could those attributes be set to zero so that no html attribute is output, so that browsers could scale (similar to image_article)?

edit// I guess the img tag could be hard-coded without those attributes and use the plugin to output the src att…

Last edited by wolfcry911 (2011-04-02 02:14:24)

Offline

#146 2011-04-10 17:50:23

wolfcry911
Member
From: MA, USA
Registered: 2006-06-30
Posts: 51

Re: smd_random_banner: Random banner image for advertising

Bloke,
What would be involved in having the script output html instead of xhtml (specifically the closing ‘/>’ of images)?

Offline

#147 2011-04-10 20:04:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,246
Website GitHub

Re: smd_random_banner: Random banner image for advertising

wolfcry911 wrote:

Could height and width attributes be added so as to override the value stored in the database.

Hmmm, this plugin is showing its age. Currently it’s not easy because of the way the output templates are generated; the width and height are hard-coded into the image template. I had grand designs (once upon a time) to allow you to specify your own template formats which would then permit you to define exactly what was output. I never pursued this; primarily because it was a lot of extra code for very little gain. So I guess the answer is no at the moment.

However, if you wanted to do it yourself you could probably hack the plugin. Line 55 defines the Image format template:

"Image" => array('<img src="@@data" width="@@width" height="@@height" @@others />', ''),

You could probably alter this to:

"Image" => array('<img src="@@data" @@others>', ''),

without any ill effetcs (though it’s untested). Note I’ve also removed the trailing / to cater for your second request of HTML compliance.

Alternatively, for finer-grained control, you could add an extra template called, I dunno, HTMLImage like this:

"Image" => array('<img src="@@data" width="@@width" height="@@height" @@others />', ''),
"HTMLImage" => array('<img src="@@data" @@others>', ''),

And then alter the $objMimeType list (from line 30 onwards in the code) to use your new template under certain circumstances, e.g. you could tell:

"jpg" => array("image/jpeg", "HTMLImage"),

so that only JPGs get the special treatment.

This plugin really is quite hamfisted in its approach and I’d love to rip it apart one day to make it more flexible *sigh* In the meantime I hope that helps.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#148 2011-04-12 01:16:33

wolfcry911
Member
From: MA, USA
Registered: 2006-06-30
Posts: 51

Re: smd_random_banner: Random banner image for advertising

Thanks Bloke,
I did try changing the Image => array, eliminating the width and height attributes as well as the trailing /, but to no affect. I’ve tried deactiving/reactiving, logging out and in, clearing cache, restating the browser, restarting the computer (and hence the server) and still nothing. Is there anything in the smd_lib that would override this?

This is what that line looks like now (just like yours above):

"Image" => array('<img src="@@data" @@others>', ''),

Last edited by wolfcry911 (2011-04-12 01:17:46)

Offline

#149 2011-07-26 15:41:06

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: smd_random_banner: Random banner image for advertising

Bloke:

Is it possible to put a limit on how many times a banner will be show? i.e. I want a banner to be displayed only x amount of time and/or I want a banner displayed until December 1?

progre55

Offline

#150 2011-07-26 15:47:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,246
Website GitHub

Re: smd_random_banner: Random banner image for advertising

progre55 wrote:

Is it possible to put a limit on how many times a banner will be show?

Not natively in the plugin. You could perhaps tally the number of times a particular banner has been displayed using rvm_counter but I don’t know if you can “get at” the info since this plugin (stupidly) doesn’t have container support. Can you tell it was my first plugin :-)

Not sure how you’d do this, sorry. Perhaps with another plugin!


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#151 2011-07-26 15:48:26

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: smd_random_banner: Random banner image for advertising

thanks.

progre55

Offline

#152 2011-07-26 16:39:14

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,744
Website

Re: smd_random_banner: Random banner image for advertising

Bloke wrote:

Not natively in the plugin. You could perhaps tally the number of times a particular banner has been displayed using rvm_counter…

I’m always just focking stunned at how well you know you’re plugins work (or not) with other plugins…

As if you don’t already have enough plugins (among other things) of your own to keep straight.

Impressive.

Offline

#153 2012-10-22 06:24:48

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 858
Website

Re: smd_random_banner: Random banner image for advertising

Hey Stef – how’s things?

The urls were not validating for me…. so I took a look in the code and changed this (line 266 on my file):

$varstr = do_list($paramVal, “&”);

to this

$varstr = do_list($paramVal, “&amp;”);

and it validated :)

nope, I was lying – it doesn’t work

Last edited by tye (2012-10-22 07:06:12)

Offline

#154 2021-04-01 00:31:53

visualpeople
Member
From: Corvallis, Oregon - USA
Registered: 2005-11-16
Posts: 73
Website

Re: smd_random_banner: Random banner image for advertising

** Update **
Disregard my ramblings below, I think I pretty much figured out a way around this with <txp:images> Sorry to bother you.

I feel like I may be exhuming some ancient relic by posting here, but here I go…

I’ve got a super old (shocker!) site using this & smd_random_txt to show three images in a row (I can’t for the life of me remember exactly why) but it works and has for ages now.

However, today, I upgraded from Txp 4.8.2 straight to 4.8.5 and I suspect something in the image tag change in 4.8.3 may have messed things up???

Anyway, with smd_random_banner tag on a page I’m getting this error:

Fatal error: Uncaught Error: Call to undefined function image() in /home/xxx/public_html/textpattern/plugins/smd_random_banner/smd_random_banner.php:336 Stack trace: #0 [internal function]: smd_random_banner(Array, NULL) #1 /home/xxx/public_html/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func('smd_random_bann...', Array, NULL) #2 /home/xxx/public_html/textpattern/lib/txplib_publish.php(549): Textpattern\Tag\Registry->process('smd_random_bann...', Array, NULL) #3 /home/xxx/public_html/textpattern/lib/txplib_publish.php(406): processTags('smd_random_bann...', 'category="banne...', NULL, false) #4 /home/xxx/public_html/textpattern/plugins/smd_random_text/smd_random_text.php(174): parse('\r\n<txp:smd_rand...') #5 [internal function]: smd_random_text(Array, '\r\n<txp:smd_rand...') #6 /home/xxx/public_html/textpattern/vendors/Textpattern/Tag/Registry.php(140): call_user_func('smd_random_text', Array, '\r\n<txp:smd_rand...') #7 /home/xxx/public_html/textpattern/lib/txplib_publish.php(54 in /home/xxx/public_html/textpattern/plugins/smd_random_banner/smd_random_banner.php on line 336

and line 336 of smd_random_banner.php is:

						$objOut = (($thumb) ? thumbnail($imgOptions) : image($imgOptions));

Running all the latest smd_random_banner (.42), smd_random_text (.14) and smd_lib (.37) plugins and PHP 7.4 on this server…

Any thoughts on something I could do to fix this in less than 5 minutes?

If not it’s completely fine, I’ll try something else or maybe use this as leverage to get this client to FINALLY update their site…

- Ryan

Last edited by visualpeople (2021-04-01 00:45:58)

Offline

#155 2021-04-01 06:39:14

etc
Developer
Registered: 2010-11-11
Posts: 4,252
Website GitHub

Re: smd_random_banner: Random banner image for advertising

Hmm, yes, since the introduction of global attributes, direct calls to ‘tag’ functions are deprecated. Some of these functions get removed/replaced, as it was the case of image() in 4.8.5. You can replace image($imgOptions) with thumbnail($imgOptions + array('thumbnail' => false)), but a more future-proof way would be using processTags():

processTags('image', $imgOptionsString);

Offline

#156 2021-04-01 07:36:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,246
Website GitHub

Re: smd_random_banner: Random banner image for advertising

Glad you got it sorted. This plugin is so ooooold. I should stop using direct calls and throw everything through parse(). Thanks for the report


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB