Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Images placed on elipse shape

  1. #11
    Join Date
    May 2012
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Oh, one more thing - I'm styling images like
    PHP Code:
        <img src="<?php echo $url?>" style="height:46px;width:auto;">
    but few of them should be bigger, than this height. How to do that?

  2. #12
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Just add another argument to the function for width (and/or height), I guess. Or let it be determined automatically. There are also some functions in PHP for automatically generating image tags including the dimensions, so you could use that if you want.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #13
    Join Date
    May 2012
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Now it looks like
    PHP Code:
          <?php
        
    function imagecode($url,$x,$y,$h) {
        
    ?>
        <div style="display:block;position:absolute;left:<?php echo $x?>;top:<?php echo $y?>;">
        <img src="<?php echo $url?>" style="height:<?php echo $h?>;">
        </div>
    and it works, but I'm getting error: Notice: Undefined variable: h when one of pictures is missing height value, when value is present it's all ok. Is it correct behaviour?

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It isn't optional. If you want it to be optional, you could try this, by setting a default value:
    function imagecode($url,$x,$y,$h='auto') {

    That will use the value of "auto" unless $h is specified in the function.

    So now you can do either of the following:
    imagecode('myimg.jpg',10,50,35); //35px height
    imagecode('myimg.jpg',10,50); //default 'auto' height



    One note: the way it's designed (and due to the flexibility of PHP) you can use either numbers (eg, 30) or strings (eg, '30px') for this. Your choice, based on what you want the HTML to look like in the end.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. The Following User Says Thank You to djr33 For This Useful Post:

    Lestatt (06-05-2012)

  6. #15
    Join Date
    May 2012
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Thanks again. I was close :P

  7. #16
    Join Date
    May 2012
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    I'm trying to make that $rollover_url working, but in best case rollover image is placed to the right of the main image. How exactly should it be written?

    PHP Code:
          <?php
        
    function imagecode($url,$rollover_url,$x,$y,$h='auto') {
        
    ?>
        <div style="display:block;position:absolute;left:<?php echo $x?>;top:<?php echo $y?>;">
        <img src="<?php echo $url?>" style="height:<?php echo $h?>;">
        <img src="<?php echo $rollover_url?>" style="height:<?php echo $h?>;">
        </div>
        <?php
        
    }

        
    imagecode('/index_files/images/loga/same-off.png','/index_files/images/loga/same-on.png',110,-140,36);
        
    ?>
    I think I should use IF mouseover or something? Additionally every image in imagecode should be a link to website.
    Last edited by Lestatt; 06-06-2012 at 07:31 AM.

  8. #17
    Join Date
    May 2012
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Ok, now my code looks like this:

    PHP Code:
          <?php
        
    function imagecode($url,$hover_url=''$x,$y,$h='auto') {
        
    ?>
        <div style="display:block;position:absolute;left:<?php echo $x?>;top:<?php echo $y?>;">
        <img src="<?php echo $url?>" style="height:<?php echo $h?>;" 
        onmouseover="this.src='<?php echo $hover_url ?>'" onmouseout="this.src='<?php echo $url ?>'">
        </div>
        <?php
        
    }
        
    imagecode('/index_files/images/loga/same-off.png','/index_files/images/loga/same-on.png',120,-140,36);
        
    imagecode('/index_files/images/loga/deutz-off.png','/index_files/images/loga/deutz-on.png',300,-80,36);
        
    imagecode('/index_files/images/loga/kuhn-off.png','/index_files/images/loga/kuhn-on.png',450,-10,66);
        
    imagecode('/index_files/images/loga/rauch-off.png','/index_files/images/loga/rauch-on.png',520,100,76);
        
    imagecode('/index_files/images/loga/weidemann-off.png','/index_files/images/loga/weidemann-on.png',360,180,46);
        
    imagecode('/index_files/images/loga/mx-off.png','/index_files/images/loga/mx-on.png',350,270,36);
        
    imagecode('/index_files/images/loga/joskin-off.png','/index_files/images/loga/joskin-on.png',110,340,36);
        
    imagecode('/index_files/images/loga/feraboli-off.png','/index_files/images/loga/feraboli-on.png',-110,250,66);
        
    imagecode('/index_files/images/loga/krone-off.png','/index_files/images/loga/krone-on.png',-200,180,36);
        
    imagecode('/index_files/images/loga/trioliet-off.png','/index_files/images/loga/trioliet-on.png',-260,90,36);
        
    imagecode('/index_files/images/loga/dondi-off.png','/index_files/images/loga/dondi-on.png',-200,0,36);
        
    imagecode('/index_files/images/loga/agromec-off.png','/index_files/images/loga/agromec-on.png',-120,-80,36);
        
    imagecode('/index_files/images/loga/orsi-off.png','/index_files/images/loga/orsi-on.png',150,200,86);

        
    ?>
    and everything works. The only problem is to make every image a clickable link. A can't figure out solution.

  9. #18
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Add an <a> tag around the image and again add a new argument to the function, call it $link or whatever you want. Now that you've got this base, there's no reason you can't change what you need. (And this is why I like PHP-- in the end, even if it's a little hard to set up, it saves time.)

    Something like this:
    PHP Code:
          <?php
        
    function imagecode($url,$hover_url='',$link$x,$y,$h='auto') {
        
    ?>
        <div style="display:block;position:absolute;left:<?php echo $x?>;top:<?php echo $y?>;">
        <a href="<?php echo $link?>">
            <img src="<?php echo $url?>" style="height:<?php echo $h?>;" 
            onmouseover="this.src='<?php echo $hover_url ?>'" onmouseout="this.src='<?php echo $url ?>'">
        </a>
        </div>
        <?php
        
    }

        
    imagecode('/index_files/images/loga/same-off.png','/index_files/images/loga/same-on.png','http://google.com',120,-140,36);
    //...

        
    ?>
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. The Following User Says Thank You to djr33 For This Useful Post:

    Lestatt (06-06-2012)

  11. #19
    Join Date
    May 2012
    Posts
    29
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Hah, I was so close to the solution, just forgot to add <?php echo $link; ?>"> and instead of that I tried to do something like closing entire "imagecode..." line in <a href> tag.
    Thanks, you are helpful as always. It works like a charm.

    Just tell me one more thing. On another forum people said it's "Bad" to make onhover effect in PHP and i should do that with css/jQuery. Is it right? May I have any problems with PHP onhover?

  12. #20
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The PHP is irrelevant. PHP (and other serverside languages) generate HTML. They don't "do" anything on the page.
    If you go to your page and click view>source, you'll see the real source code.
    PHP operates on the server and then prints out plain text-- HTML. This HTML is designed (in what we've done) to include the onmouseover stuff and whatever. But the PHP doesn't do anything at all to it. It's just like an extra hand writing the code for you. That's why I suggested using PHP here-- it automates the processing of generating the same code 13 times, or whatever you need. You could completely remove the PHP from this if you'd like-- view>source, then copy all of that into a new document. It would work perfectly. But then you'd lose the ability to edit all 13 images by editing one bit of code. Personally, I think leaving the PHP there is more organized. It'll save you time if you ever need to update it.

    And you are using Javascript. onmouseover and onmouseout are Javascript events. You do not need jQuery for this. jQuery is a library of shortcuts and extensions for Javascript, but if you aren't doing anything fancy, it will just be an extra thing to load.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  13. The Following User Says Thank You to djr33 For This Useful Post:

    Lestatt (06-06-2012)

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
  •