SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting the image url

    I am wondering if someone could please tell me how I can get the url of the last image that was created? Thanks in advance.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Um...sorry but we cannot do anything with such a vague question with no code.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the image will be created using php. So once the image is saved to the server I would like get that image's url.

    Here is my code:
    Code PHP:
    // more code is here
    			function makeimage($pagetitle) {
    				$button = str_replace(' ', '', $pagetitle);
    				$button2 = strtolower($button);
    				header("Content-type: image/jpeg");
    				$im = @imagecreate(200, 23)
    				or die("Cannot Initialize new GD image stream.");
    				$background_color = imagecolorallocate($im, 0, 57, 122);
    				$text_color = imagecolorallocate($im, 255, 255, 255);
    				imagestring($im, 3, 10, 5,  $button2, $text_color);
    				$button2 = imagejpeg ($im, $button2."btn.jpeg");
    				imagedestroy($im);
    			}
    			makeimage($pagetitle);
    // more code is here

  4. #4
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your filename is going to be
    PHP Code:
    echo $button2."btn.jpeg"
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  5. #5
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried what you said wheeler however it won't print on the screen. I placed that piece of code in the function and it didn't work. Then I placed it outside the function and it didn't work. So can you or someone please tell me how I can get it to print on the screen? Thanks in advance.

  6. #6
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Paste here what this displays:

    Code:
    // more code is here
                function makeimage($pagetitle) {
                    $button = str_replace(' ', '', $pagetitle);
                    $button2 = strtolower($button);
                    header("Content-type: image/jpeg");
                    $im = @imagecreate(200, 23)
                    or die("Cannot Initialize new GD image stream.");
                    $background_color = imagecolorallocate($im, 0, 57, 122);
                    $text_color = imagecolorallocate($im, 255, 255, 255);
                    imagestring($im, 3, 10, 5,  $button2, $text_color);
                    $button2 = imagejpeg ($im, $button2."btn.jpeg");
                    imagedestroy($im);
                    echo $button2."btn.jpeg";
                }
                makeimage($pagetitle);
    // more code is here

  7. #7
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,411
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    Lets see if this is correct:
    $button = str_replace(' ', '', $pagetitle);
    so
    $button2 = strtolower(str_replace(' ', '', $pagetitle));
    Then
    $button2 = strtolower(str_replace(' ', '', $pagetitle))."btn.jpeg";

    Anyway something like that.

    Try
    PHP Code:
    echo "<img src=\"".$button2."\">"

  8. #8
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bohboh, on the screen it prints http://www.blueguminteractive.biz/folder/test123.php which is the url of the php file with the image code. When I right clicked for the source code it displays: 1btn.jpeg. Which I would prefer to be displayed on the screen.

    Rubble, I tried what you said but this is what displayed on the screen http://www.blueguminteractive.biz/folder/test123.php which is the url of the php file with the image code. And when I right clicked for the source code it displayed: <img src="">.

  9. #9
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unless your echoing between some strange tags or perhaps in the <head> </head> of the page there is no reason why it wouldn't display on the page.

    perhaps put it in h1 tags so your sure it is not mixed in with other content somewhere.
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

  10. #10
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry guys, I was testing it in Firefox. However when I tested it in IE it worked. Thanks everyone for your help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •