gerbenjacobs / HabboAPI

A PHP wrapper for the (undocumented) Habbo API
MIT License
44 stars 10 forks source link

getThumbnailOrDefault #11

Closed gerbenjacobs closed 8 years ago

gerbenjacobs commented 8 years ago

Apparently the Room entity has two images; ThumbnailUrl (occasionally works if set by a Habbo) and ImageUrl (not working at the moment, it appears)

So perhaps add a little helper function to the Room entity that you can query and give a default 'backup' image. It will check the URL and return the URL if valid or it will return the fallback URL.

$room = new Room();
$room->parse($room_data);

echo '<img src="' . $room->getThumbnailOrDefault('/images/default_room.png') . '" alt="My room">';
DavydeVries commented 8 years ago

To come back on your own comment:

Yep, because if you really think about it, flag icons are a UI/View problem.

If you use the thumbnail url as a background-image inline. And in CSS a fallback url background-image. You have no problems with this.

CSS:

.roomimg{
background-image:url(xxx.png);
}

HTML:

<div class="roomimg" style="background-image:url(thumbnail_url.png)"></div>

So my conclusion, it's a UI/View problem. And easy to fix for a user/developer.

gerbenjacobs commented 8 years ago

Yeah, I'm also reconsidering the flag thing. Not necessarily to start using hhus, but to have a little helper function that can transform com to hhus and vice versa.

The background image is a good idea. But that doesn't work for normal images (without JS).

But the main problem I find is that Habbo (and thus we as well) return a fully valid HTTPS URL, but then in the end.. it doesn't even work. The ideal situation would be Habbo returning null.

The next best situation would maybe be that our HabboAPI is more user-friendly?

DavydeVries commented 8 years ago

But that doesn't work for normal images (without JS).

Image element is so unfriendly elements in HTML, I recommend to drop this and start using background-images. (But this is my opinion.)

gerbenjacobs commented 8 years ago

Closing this particularly issue, the actual functionality might be built in #15.