1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Can php detect "if" an image is returned?

Discussion in 'Web Design & Development' started by BlackFrancis, Apr 4, 2018.

Thread Status:
Not open for further replies.
Advertisement
  1. BlackFrancis

    BlackFrancis It's My Birthday! Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    212
    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.
     
  2. BlackFrancis

    BlackFrancis It's My Birthday! Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    212
    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.
     
  3. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,195
    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%
     
  4. BlackFrancis

    BlackFrancis It's My Birthday! Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    212
    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.
     
  5. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,195
    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 ...
     
  6. BlackFrancis

    BlackFrancis It's My Birthday! Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    212
    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.
     
  7. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,195
    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'
     
  8. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,182
    First Name:
    Colin
    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.
     
  9. BlackFrancis

    BlackFrancis It's My Birthday! Thread Starter

    Joined:
    Oct 21, 2006
    Messages:
    212
    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.
     
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Tags:
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1208020

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice