LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 July 9 2010

Kassem
Member

Images Do Not Show Up?

Hey guys,

Two days ago, I was assigned to work on a pre-existing project which is a PHP website for some real estate company in Lebanon. I checked the code and trust me when I tell you that's one of the nastiest code ever. It is done using PHP4 and not PHP5, the design of the code sucks big time, there is huge redundancy in the database which is just a bunch of tables that do not follow any business logic. Moreover, it's not secure at all and that's a major issue the site owner should care for. On top of that, the developer uses tables to layout the web page, html tags to style the page in addition to 5 stylesheets that override one another. The bottom line, it's an EPIC FAIL! lol

Anyway, I have no idea what the developer has done but when I try to insert an image into the page, it doesn't render at all. I know there is an image, when I right click I can save it to my hard disk and I used a border as well. But for some reason it doesn't show up. Is there anything I could do about it?

<div>
   <span>300 x 250 - Medium Rectangle</span><br />
    <img src="images/banners/300x250.png" alt="300x250 banner" width="308" height="258" style="position:relative" border="1" /> 
</div>

Last edited by Kassem (July 9 2010)

Offline

#2 July 9 2010

rolf
Member

Re: Images Do Not Show Up?

Dont be quick to juge other persons work, they all have their strongpoint and their weakpoints, some developpers indeed produce crap code but on the good side they are reliable and workhorses...
Besides, some of the thing you mentioned are not bad in themselves...  PHP4... so what? Tables for layout? It can be ok!
But... 5 CSS files... no...
I know what you mean. I have had to deal with a horrible code too, the PHP was totally mixed with html, and it was all function with weird names (like print_but, which would take 3 arguments, and print an html button), some of them 100s of line long. And no documentation. And I had a skype chat with the "developer" in question... he never ever heard of phpinfo().
Anyway, to cut the chase, you can use Firebug for your question above, to check if there is CSS (like "display") that hides it, or javascript that modifies it.
And also, I recommend telling upfront to the client that the code is unmanageable, and that delays cant be guaranteed, because it will come down to that, and you will have to tell him that when he becomes angry about the delays, so you might as well warn him while you're on good terms. He will understand, and if he dont, then he will go around other developers and when he always gets the same result he will understand in the end. So ma fi mahrab.
Good luck.

Last edited by rolf (July 9 2010)

Offline

#3 July 9 2010

Ayman
Member

Re: Images Do Not Show Up?

It may be a bit off-topic but I remember once I read somone's code with one single if statement which was like:

//some code

if(true)
{
   // do something
}
// other code statements

I was WTF! why put an if in the 1st place!

Last edited by Ayman (July 9 2010)

Offline

#4 July 9 2010

rolf
Member

Re: Images Do Not Show Up?

AymanFarhat wrote:

It may be a bit off-topic but I remember once I read somone's code with one single if statement which was like:

//some code

if(true)
{
   // do something
}
// other code statements

I was WTF! why put an if in the 1st place!

Probably so he can "enable" or "disable" that block of code (during development), by only changing one word.

Offline

#5 July 9 2010

Ayman
Member

Re: Images Do Not Show Up?

rolf wrote:
AymanFarhat wrote:

It may be a bit off-topic but I remember once I read somone's code with one single if statement which was like:

//some code

if(true)
{
   // do something
}
// other code statements

I was WTF! why put an if in the 1st place!

Probably so he can "enable" or "disable" that block of code (during development), by only changing one word.

Most probably yeah but I still find it stupid especially when he is claiming that this is the final version of his code.

Offline

#6 July 9 2010

Kassem
Member

Re: Images Do Not Show Up?

rolf wrote:

And also, I recommend telling upfront to the client that the code is unmanageable, and that delays cant be guaranteed, because it will come down to that, and you will have to tell him that when he becomes angry about the delays, so you might as well warn him while you're on good terms. He will understand, and if he dont, then he will go around other developers and when he always gets the same result he will understand in the end. So ma fi mahrab.

Actually I already made it clear to the client that the existing code is useless. He SHOULD rebuild the website, and he's waiting for the right time now. Meanwhile, I'll take care of maintaining the website and fixing stuff from time to time.
There's a bunch of messy Javascript code in the header of the top.php page. And the 5 CSS files as well,I'll use Firebug like you suggested, this might be the only way. Thanks for the help man :)

Offline

#7 July 9 2010

Kassem
Member

Re: Images Do Not Show Up?

I think the problem is in the images themselves... I tried to find the problem using firebug but I couldn't find any issues with the CSS. When I mouse over the source code of the image inside firebug, I'm getting a white box and not the image. Check it out please: http://www.happyhomelb.com/banner_rect.php

Offline

#8 July 9 2010

rolf
Member

Re: Images Do Not Show Up?

Kassem wrote:

I think the problem is in the images themselves... I tried to find the problem using firebug but I couldn't find any issues with the CSS. When I mouse over the source code of the image inside firebug, I'm getting a white box and not the image. Check it out please: http://www.happyhomelb.com/banner_rect.php

If it's medium rectangle you are talking about, it shows up properly, in FF3.6, with inside the text "300 x 250", but no rollover. Is it normal? Also try different browsers.

Last edited by rolf (July 9 2010)

Offline

#9 July 9 2010

Joe
Member

Re: Images Do Not Show Up?

Ouch!

* table layout
* CSS and javascript inside every tag.
* Very vulnerable search form. It doesn't even have a method. I cannot imagine what's in "/search.php"

About your image problem, Firebug shows a 'display:none' attribute. It could come from one of the CSS files, or Javascript (most probable guess).

Your best bet is to explain to the owner that the website is functional, but maintainability is poor. And that it is in his best interest, if he wants to have the website evolving, to let you recode it from the start :)

Good Luck :-S

Offline

#10 July 9 2010

Kassem
Member

Re: Images Do Not Show Up?

rolf wrote:

If it's medium rectangle you are talking about, it shows up properly, in FF3.6, with inside the text "300 x 250", but no rollover. Is it normal? Also try different browsers.

Yes that's exactly what should appear. Do all the images appear? I tried 3 different browsers and the images did not show up in any of them. Weird.

@rahmu: Amen to that lol.

Offline

#11 July 9 2010

Joe
Member

Re: Images Do Not Show Up?

Images show nice when clicking on your link. But when clicking on any link in the website, they disappear. Seems like javascript to me...

Offline

#12 July 9 2010

Joe
Member

Re: Images Do Not Show Up?

Found it!

It seems the left menu has an onclick javascript that goes

onclick="javascript:display_ShowHide('menu3','div')"

It is the one hiding your images when clicked. But if you get rid of it, you'll lose your interactive menus.

I diagnosed the problem, but the solution might be a bit hard to find...

Last edited by Joe (July 9 2010)

Offline

#13 July 9 2010

Kassem
Member

Re: Images Do Not Show Up?

I see... When I saved the image to my desktop, I got a white pixel image (only ONE pixel). Then I disabled javascript using the Web Developer toolbar and refreshed the page, but still nothing changed...

Offline

#14 July 9 2010

Kassem
Member

Re: Images Do Not Show Up?

rahmu wrote:

Found it!

It seems the left menu has an onclick javascript that goes

onclick="javascript:display_ShowHide('menu3','div')"

It is the one hiding your images when clicked. But if you get rid of it, you'll lose your interactive menus.

I diagnosed the problem, but the solution might be a bit hard to find...

hmmm... I'll have to look into that, do you think that taking the images out of the div tags would solve the problem?

EDIT: nope, doesn't solve anything.

Here's the function:

function display_ShowHide(id,type) {
    var target = document.getElementById(id);
    var all = document.getElementsByTagName(type);
    for (var i = 0; i < all.length; i++) {
         all[i].style.display = "none";
    }
    if (target.style.display == "none") {
         target.style.display = '';
         return true;
    }
if (target.style.display == '') {
         target.style.display = 'none';         
           return true;
    }

}

Will have to look into it tomorrow. It's late over here...

Last edited by Kassem (July 9 2010)

Offline

#15 July 9 2010

Joe
Member

Re: Images Do Not Show Up?

var all = document.getElementsByTagName(type);

This line says that it is hiding all the <type> tags. Idiot uses it to hide all the div tags.

Replacing <div> with <span> is a solution. I tested it on my computer it works.

Remember, this solution will not fix the problem, only buy you time for you to explain to your client how bad this website is made.

Offline

Board footer