News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Want placeholder image for broken img links

Started by scrapper, March 22, 2018, 09:51:56 AM

Previous topic - Next topic

scrapper

Hi, it seems that SMF is displaying nothing if an [img] tag has a broken link in it. How can I have SMF display a placeholder image (anything, really, I just need to know that there is a broken link)?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GigaWatt

I think this is the default behavior in SMF. It just doesn't show anything if there is a broken image link.

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

lurkalot

Quote from: GigaWatt on March 23, 2018, 02:51:19 AM
I think this is the default behavior in SMF. It just doesn't show anything if there is a broken image link.



Quote from: Kindred on March 22, 2018, 12:44:58 PM
that's not SMF...  that's your browser.

Try viewing the site in IE11 or edge, and you'll see the image placeholders.

GigaWatt

That's basically just one browser out of... well, probably hundreds of others out there... not to mention that it's not open source and that it officially works under one operating system ::).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Kindred

it is not default behavios in SMF...   it's the default behavior OF THE BROWSER, as I said in the first place.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GigaWatt

I get what you're trying to say, the script can't display the image because it's not there, so every browser, except for IE and Edge, just displays... nothing... an empty line.

Is there a mod that can fix this, as the OP said, to display a generic image (any image that the admin assigns)?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

drewactual

if it's something that you want to defeat, you can use css to place a frame around img's in post's, and add background image to that frame- while providing a minimum width of, say, 25px so it will display whenever it encounters img within posts, but a picture of any appreciable size covers the background image when a picture is really there. 

Illori

SMF does not know if the image is at the link or not. i dont think there is a way SMF can do this even with a mod it may make things very slow on pages that have these links if one was made.

GigaWatt

Quote from: Illori on March 23, 2018, 11:25:27 AM
SMF does not know if the image is at the link or not.

Aha ;). Thanks ;).

It basically means that the mod had to check if the image was present (if something is loading), and if something is, display the image / continue to load it and display it, if not, display the "missing image" image.

I get it now, thanks for making things clearer ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

drewactual

something like:


.post .inner img{border:1px solid #000; background:url(urltoimage) no-repeat; min-width:25px; height:auto;}


added to your css ought to suffice...

SMF doesn't, to my knowledge, qualify an image... it simply presents it if there really is an image... if their is not, the BROWSER displays the broken image image... 

what i've offered should work, and if the image you use as a background is something that would notify the observer of the broken link, then good-good... the only problem is if using a browser that DOES display the broken image link, at what point there would be that + the background image viewed.

@rjen

Quote from: drewactual on March 23, 2018, 11:36:07 AM
something like:


.post .inner img{border:1px solid #000; background:url(urltoimage) no-repeat; min-width:25px; height:auto;}


added to your css ought to suffice...

Interesting idea, tested it but it has some undesired side effects: it will increase the size of the smileys in te forum too and add a border to them. In addition (partially) transparent images will also show the background image...

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

drewactual

Aye... Could do something simpler then, such as no borders with a small, say 4x4pixel dot in upper left or right corner... All post pics would have it, but it would hardly be noticeable for those with images.

@rjen

#13
This seems to work.

Put a 'broken image' icon in a folder and added this to the css




.post .inner img.bbc_img:before {
content: url(addyoururlhere/broken.jpg);
}


Chrome shows this icon now for broken images, IE shows it's own, need to check other browsers...

OK, this is a very partial solution: it helps on Chrome but not on Firefox. Most brwosers seem to not support the :before statement... but again, interesting stuff to play with...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

GigaWatt

I'm not a web coder, my knowledge in PHP ends with a very limited knowledge of Java (it never appealed to me, I'm kind of used to low level stuff), but I think the real problem would be, how do you decide whether an image is loading or not?

As I said, I'm not a web coder, so this may sound like a stupid question, but... can PHP do this?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Kindred

#15
Only by attempting to load it and then do something to it...   it would be a complete and utter waste of server resources
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GigaWatt

Well, I'm paying for the sucker, so it should do what I tell it to, right :D?

And BTW, what is "attmelt8ng". I tried googling, but it didn't return anything relevant.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Kindred

well - any decent developer SHOULD tell you that it is a waste of resources...  and may actually violate some terms of service, since your system would have to download the file in order to check it...

as for the word...  mistype on mobile with fat fingers.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GigaWatt

About the server... I was only joking :D. I'm not planing on abusing the server for my own personal needs ;).

But, than again... is abusing the server making it load the same image twice? Sure, a waste of bandwidth, but abuse... I think that's going a bit far :).

Okay, let's say you've set your forum to show 50 posts per page and there is one single image in each post. That means that if each of the images had to load twice, the server would have to run the same command 100 times. But, what if you've set your forum to load 25 posts per page. Does this mean you're lenient, LOL :D?

I think this sort of thing should be up to the user (creator of the forum, admin) ;)... and just in case someone also wants to say "you're not just gonna load this image twice, but you're gonna keep it on you at all times, arrrggghhhh", you could have some sort of a filtering mechanism, like external images only ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

@rjen

I did some digging and it seems Firefox and chrome seem to favor showing the alt text instead of an icon for broken images . Problem is that most users do not specify an alt text when adding image links in posts.

It may be easier to make a fix in the smf code to set a default alt text for all images in posts in case no specific alt text is given?

Can anyone suggest a direction or code fix to do that?
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Advertisement: