phpBB SnippetsRandom background image in text area

Post Reply
User avatar
Topic Starter
Restless Rancor
Great Britain

Site Admin
New Member
Posts: 48
Joined: October 15th, 2018, 3:14 pm
Age: 25
Location: Hampshire, England
Contact:

Random background image in text area

#1

Post by Restless Rancor » October 16th, 2018, 2:32 pm

This snippet randomizes the image displayed in the text area, which is added by the background image in text area extension.



Tested On:


Open: root/ext/alex75/imageintextarea/styles/prosilver/template/event/overall_header_head_append.html

Replace everything with:

Code: Select all

{% set rand = random([1, 2,]) %}
{% if rand == 1 %}
    <!-- INCLUDECSS @alex75_imageintextarea/image.css -->
{% elseif rand == 2 %}
    <!-- INCLUDECSS @alex75_imageintextarea/image2.css -->
{% endif %}
Open: root/ext/alex75/imageintextarea/styles/prosilver/theme/image.css

Find:

Code: Select all

background: #FFFFFF url("./message.png") right bottom no-repeat;
In-Line Find:

Code: Select all

message
In-Line Add After:

Code: Select all

2
Note: Save this as a new file: root/ext/alex75/imageintextarea/styles/prosilver/theme/image2.css

To add more images you need to change the random([1, 2,]) and add more {% elseif rand == X %} and <!-- INCLUDECSS @alex75_imageintextarea/imageX.css -->.
The example below is for four random images. Remember you need a new image.css file per image and each image needs to be named messageX.png where X is the number.

Code: Select all

{% set rand = random([1, 2, 3, 4,]) %}
{% if rand == 1 %}
    <!-- INCLUDECSS @alex75_imageintextarea/image.css -->
{% elseif rand == 2 %}
    <!-- INCLUDECSS @alex75_imageintextarea/image2.css -->
{% elseif rand == 3 %}
    <!-- INCLUDECSS @alex75_imageintextarea/image3.css -->
{% elseif rand == 4 %}
    <!-- INCLUDECSS @alex75_imageintextarea/image4.css -->
{% endif %}
Note: After you upload the changed and new files, purge the board and browser cache.
You may need to copy the content of root/ext/alex75/imageintextarea/styles/prosilver/* to [c]root/ext/alex75/imageintextarea/styles/YOUR_STYLE/* where YOUR_STYLE is the name of yours style.
Changelog:
► Show Spoiler


These aren't the droids you're looking for.

Post Reply

Topic Subscribers

1 user subscribed to this topic: Restless Rancor