/    Sign up×
Community /Pin to ProfileBookmark

User adds code, they get new image daily

What I want to be able to do is give people a small amount of code to add to their website, and from that a new image will be displayed daily (simply retrieving the location from a database or something that I add everyday).

Is javascript the thing to use to accomplish this?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@r_soleauthorDec 21.2007 — Alright I decided on a way to do this, though I think it may lead to problems..

I just made a .js file and made it write what I wanted. Eg:
[CODE]document.write("<img alt='daily image' src='http://www.WEBSITE/images/image.jpg'>[/CODE]

The way this .js file gets updated is - I put a line of code in the upload script, that I use to upload my images everyday, which replaces the contents of the .js file with the same thing but the 'image.jpg' part would be altered (eg 'image2.jpg').

I don't know, it just feels like a bad way to do it. Like there could be problems. I've seen many people instead of giving out a .js file, they give out a .cgi file. Is this possibly easier (as in it can update itself) ?

Tell me what you think. ?
Copy linkTweet thisAlerts:
@Declan1991Dec 21.2007 — What people do is they use a server side language that actually returns an image, not just a link to an image. For example, they link to http://www.WEBSITE.com/images/image.php and then in PHP use:

header("content-type","image/jpeg"); etc. but that is a PHP or any other server side issue.
Copy linkTweet thisAlerts:
@r_soleauthorDec 21.2007 — Awesome, thanks man.

Just for anyone else who was curious, what went into my php file was this:

[code=php]
<?php
// Set header
header("content-type","image/jpeg");

//create image
$image = imagecreatefromjpeg("http://www.WEBSITE.com/images/image1.jpg");
imagejpeg($image);
?>
[/code]


It was actually a bit different to this, but thats the basic idea.

Thanks again Declan.
Copy linkTweet thisAlerts:
@r_soleauthorDec 21.2007 — The only bad thing about doing it the PHP way is that I don't have as much control over what the people are adding to their site.

For example, by using the javascript file I can make sure that the image that they get is also a link back to my site. I can also make sure that there is a border around the image and other things like that.

So there's not someway that they can add a .js or a .cgi file that somehow runs a server-side script on my site, that will return the image? Or some other way?

It doesn't really bother me, I'd use the php way if I needed to. Just curious now.
×

Success!

Help @r_sole spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...