Tech Support Guy banner

Can php detect "if" an image is returned?

1043 Views 8 Replies 3 Participants Last post by  BlackFrancis
Hi folks,
I'm boxing above my weight here, but I have a project I'm passionate about. Any pointers would be appreciated.

Found this nifty PHP tutorial on returning a random image from a folder
http://alistapart.com/article/randomizer/

Direct link to PHP

Works a charm, but I need to somehow display a few lines of text associated with each image below the output. Say the script displays /Ace of Cups.jpg a conditional statement echos a description of the card image.

Am I telling the PHP to react to a printed URL or some other PHP yokimahbob? How might I go about that with my current code? Do I need a different method? Should I use Javascript instead? Which is the least server-and-bandwidth-intensive method?

Thanks in advance for your time. I'll throw a few Euro in the pot. It's about time.

Concept

On page load:

Random statement to give card particular significance

IMAGE

Short blurb about card in image.
See less See more
Status
Not open for further replies.
1 - 9 of 9 Posts
Never mind. I could just write some PHP to return another random PHP file. DERP.

I'm still curious if PHP can detect printed HTML.
PHP can let you know if the image exists, using the file_exists function. But, being a server side language it cannot tell you if it was rendered by the browser. But if it exists, then the likelihood of it being rendered is (IMHO) 100%
Jim! Long time!

The file wouldn't necessarily be rendered if it wasn't randomly selected to be on that particular execution.

I had found my code for my solution to just randomly displaying php files with both image and text. Then I found out the Wordpress theme I made a child theme from seems to be broken in such a way I can't use its files as a custom template? At that point I gave up on life and reconsidered alcoholism.
Haha! Alcoholism is definitely not an option, Howard;)
Come May 1st I will have been sober 18 years:) But back to the thread - I'm no WP fundi, as you well know. But if you would care to elaborate on the themes used I am sure @colinsp would be only too pleased to step in ...
Good stuff, Jim! I wish you many more years free from the shackles of "the great dissolver."
Maybe in another 5 years I'll be good enough with my php to not need Wordpress... and everything will have changed up on me again.

I searched WP for a "naked" theme I could build my own on top of. I went with Light Skeleton and suspected nothing until I tried pulling the page.php code to make a page template, which resulted in the header.php and footer.php php not being called.

Turns out the solve is to replicate both the header and footer file in the child theme. Whatever it is about this theme, because it's not how other themes operate.
Thanks for the well-wish and the WP feedback (gobbledegook to me) - I am sure that Colin will pick up on it in the morning ... go well Bro'
That is not how Wordpress Child Themes are supposed to work. The only 2 files that are required in a child theme are functions.php and style.css. The functions file should just add an action to add the file after the parent theme has loaded.

The two files you have included are 'pluggable' which means that they aren't required in the child theme but if they are then they over-ride the same files in the parent theme.

Are you sure that you did not edit out the links to those files when you edited page.php?

You should only need to put your template code immediately after a line that looks something like

PHP:
<?php theme_content();
Where theme is the name of the theme.
See less See more
Exactly. Doesn't make any sense. Even duplicating the page.php file into the child theme as-is somehow broke the links and only for the associated page. Strange, but manageable. Not the first time I took a jenga block out of someone else's tower and had it crash.
1 - 9 of 9 Posts
Status
Not open for further replies.
Top