Re: I need a widget that will display a random photo each time pages is loaded.
Excellent set of widgets Siran, worked like a charm. Saved to my web-goodies folder.
Re: I need a widget that will display a random photo each time pages is loaded.
Sculptex/Siran
Quote:
Egg, did you place the file and folder in the root? Does your sever support PHP?
I placed the php file in the same subfolder I uploaded the index pages to alongside the image folder.
Yes, never had issues with php files before:
http://www.parkeston.com/random/phpinfo.php
Re: I need a widget that will display a random photo each time pages is loaded.
Because I can't get a double url on TG server:
http://www.parkeston.com/random/random.php
Re: I need a widget that will display a random photo each time pages is loaded.
Whereas Sculptex's works as expected:
http://random.prevoo.uk/random.php
Re: I need a widget that will display a random photo each time pages is loaded.
The subdoman is not important, if you are using a subfolder then that's fine, you just need to create another folder within that called random with the images in.
So you'd have:-
public_html/random/index.htm
public_html/random/random.php
public_html/random/random/img1.jpg
public_html/random/random/img2.jpg
But Siran and Acorns solutions are better for xara anyway.
Re: I need a widget that will display a random photo each time pages is loaded.
Quote:
Originally Posted by
sculptex
The subdoman is not important, if you are using a subfolder then that's fine, you just need to create another folder within that called random with the images in.
So you'd have:-
public_html/random/index.htm
public_html/random/random.php
public_html/random/random/img1.jpg
public_html/random/random/img2.jpg
But Siran and Acorns solutions are better for xara anyway.
sculptex, that is a generous suggestion but the power of TalkGrpahics is its diversity - let's say three solutions for the OP to pick from.
I would be interested if JDunn can advise which work for the posed question.
I hope others will also try and advise back or propose their approach.
I'm obviously plugging mine as it can be changed to reflect siran's excellent solutions be including CSS styles separately and even replace the random element with a timer to cycle round as a carousel.
Acorn
1 Attachment(s)
Re: I need a widget that will display a random photo each time pages is loaded.
Hi sculptex,
I don't think your solution has any disadvantage to the others, except depending on PHP. But if your server supports PHP your solution has the advantage that replacing the images is as easy as deleting and adding files from/to a folder.
Just put your random.php file and the random folder (containing the pictures) to a support folder and it is as good for Xara as the other solutions.
After adding and/or removing pictures to/form "your support folder"/random all you need to do is re-publish or export (and later upload with FTP or such) from within Xara.
Attached is the "cover" variant of the widget examples above of your code (uploaded as a zip file because of the support folder).
The following is meant to be addressed to other readers as I guess sculptex already knows everything about it...
To change the scaling (just as Acorn already mentioned) change the "background-size:cover;" in the placeholder code to your needs (or give your DIV a class or ID and add some CSS).
Remove it to only center and no scaling,
change it to "background-size:contain;" to fit inside the placeholder,
or to "background-size:100% 100%;" to fully stretch loosing the aspect ratio,
or to "background-size:auto 100%;" to scale to same height,
or to "background-size:100% auto;" to scale to same width.
You may also change other attributes such as "background-position:center center;" to "background-position:left top;" (see for example https://www.w3schools.com/cssref/pr_...d-position.asp).
Maybe there are other useful values... Acorn or sculptex might know better.
Re: I need a widget that will display a random photo each time pages is loaded.
Finally found my problem after a few hours searching. I need to add this line to my .htaccess file
Quote:
AddType application/x-httpd-php .htm .html
Found it from this thread
Re: I need a widget that will display a random photo each time pages is loaded.
Glad you figured it out, but I don't understand why that was necessary.
Re: I need a widget that will display a random photo each time pages is loaded.
Nor do I Siran, it was just that pasting in even a very simple php code into a placeholder didn't function. It does now.