Sign in to follow this  
joedobo

Image code section in template:itemBox

Recommended Posts

Should this be done?

Is my mediawiki code right?

 

see http://www.wurmpedia.com/index.php/Template_talk:Item for past discustions where it was conculded .jpg is better.

 

Wiki template should first look for a .jpg file and use it if it exists.

 

If the .jpg is absent wiki should look for a .png and do two things if it exists. These two things are use the .png and add the file to a [[Category:png convert]]. We need to change the .png to .jpg but it would be a nightmare to look at every image. Using a category listing is a convenient way to list all .png image and we can change them over at our leisure.

 

Finally, if neither a .jpg or .png image exists we need to group these cases in [[Category:needs jpg image]]. I'm not sure what message should be displayed but a redirect to the page collecting all these instances seems appropriate[[:Category:needs jpg image|Needs image.]]

 

 

reference:


This function takes an input string, interprets it as a page title, and returns one of two values depending on whether or not the page exists on the local wiki.



{{#ifexist: page title | value if exists | value if doesn't exist }}





<!-- Check for image. If pagename.jpg doesn't exist use .png otherwise display "Needs Image" -->
{{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.jpg}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.jpg}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]
| {{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.png}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.png}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.jpg}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]
}}
}}

.


 


 


What I'm suggesting.



<!-- Check for image. If pagename.jpg exist use it. If pagename.jpg does not exists check for pagename.png and use that if it exists. Also, add png's to a category so we can see what images need to be converted. Finally, if both pagename.jpg and pagename.png don't exist add the pagename to a category listing of missing images -->
{{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.jpg}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.jpg}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]
| {{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.png}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.png}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]] [[Category:png convert]]
| [[:Category:needs jpg image|Needs image.]] [[Category:needs jpg image]]
}}
}}

Here I'll go through it line by line explaining it all.



Check if a .jpg file which has the same name as the page's name exists.



{{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.jpg}}}


if the .jpg exists use it.



| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.jpg}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]


If the .jpg does not exists check if a .png exists.



| {{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.png}}}


if the .png exists use it and add it to the png conversion category listing.



| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.png}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]] [[Category:png convert]]


if the .png does not exists add the PAGENAME to a [[category:needs jpg image]]

 

| [[:Category:needs jpg image|Needs image.]] [[Category:needs jpg image]]
}}
}}


 


  • Like 1

Share this post


Link to post
Share on other sites

I think we already had this stuff but it was removed because it created a ton of entries in the missing link pages. The change should be in the hostory of the Item template

Misinterpreted what you were planning.

Edited by ago

Share this post


Link to post
Share on other sites

@ Ago ... Here is an example page: http://www.wurmpedia.com/index.php/Plain_stone_arched_wall


We have no way of knowing how many pages don't have images at the moment. It seems to me the template can be instructed to added pages which lack an image or have the wrong image format to categories so we can see the pages in one place.


 


 


 


@ thread. I'm not sure if what I'm proposing is confusing, not many people understand wiki code (I'm not saying I do and I can sympathize why this may be the case. Its logic is very simply yet its syntax seems very complex), or simply nobody cares.


 


Also, one thing that bothers me with this is it would add pages which need an image or uses a png image to one of two categories instead of the actual "file:" pages. Its actually the "file:" pages that need to be updated.


Share this post


Link to post
Share on other sites

A new issue. It seems when we put, for example, "image=small nails.png" that the template is not running the code which ends up putting it in [[Category:png convert]]. As of this writing there is no File:small nails.jpg.


 


Would it work if we used the following?



{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }}

The idea here is to tell wiki to run the code regardless of what is happening with "image=".



<!-- Check for image. Whether "image=" is blank check or not if pagename.jpg exist use it. If pagename.jpg does not exists check for pagename.png and use that if it exists. Also, add png's to a category so we can see what images need to be converted. Finally, if both pagename.jpg and pagename.png don't exist add the pagename to a category listing of missing images -->
if{{{{{image|}}}|
{{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.jpg}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.jpg}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]
| {{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.png}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.png}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]] [[Category:png convert]]
| [[:Category:needs jpg image|Needs image.]] [[Category:needs jpg image]]
}}
}}
​|
{{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.jpg}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.jpg}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]]
| {{#ifexist: Image:{{{image|{{{name|{{PAGENAME}}}}}.png}}}
| [[Image: {{{image|{{{name|{{PAGENAME}}}}}.png}}}|center|120x120px|A {{{name|{{PAGENAME}}}}}]] [[Category:png convert]]
| [[:Category:needs jpg image|Needs image.]] [[Category:needs jpg image]]
}}
}}
}}

Share this post


Link to post
Share on other sites

First, no one cares about this given I'm almost the only one posting in this thread. It serves as good documenting either way.


 


Given the concensus here: http://forum.wurmonline.com/index.php?/topic/123350-jpg-are-prefered-image-format-why-do-folks-keep-uploading-png/


We don't need to influence JPG or PNG. Players can upload either.


 


Second, there is a problem with force running code on "image=". That problem that the filename doesn't match the page name for pages that use, for example, none.jpg or liquid.jpg. These multipurpose images are right but the code would think they need an image. We could probably put a lot of new code in the template to deal with this. But it seems much simpler and sufficient to stop where its at now.


In summary this is likely a mistake....



The idea here is to tell wiki to run the code regardless of what is happening with "image=".



 


Share this post


Link to post
Share on other sites

The PNG to JPG convert is terrible to begin with. Whenever people were asked to upload JPG because of the smaller file size, especially when PNG were saved as RGB or RGBA instead of with a colour palette, to get rid of megabyte sized images.

Nowadays I think what we should have done back then, is not trying to fallback to PNG at all and instead remove the PNG from the wiki, and have redlinks everywhere. The code is hard to read and I'd say it's unnecessary computing time. But it's not like the Wurmpedia has millions of page calls per second, so it's not noticeable. Yet, if memory serves, I was asked to have it preserve existing PNG files so the wiki wasn't void of images in a pinch.

While I agree that a category page is helpful, we could incorporate both if need be. Categories for utility, redlinks for convenience. I don't think it's more encouraging to forward everyone solely to a category page, instead of providing a redlink for something they care to lookup, and complete the article with an image. That's why I had left the category inclusion in. The category page itself doesn't forward you to the upload page, with the proper filename already preset. It's incomprehensible to me why you undid that too, since it's still showing in the bottom of the page. I was trying to meet on a middle ground but meh...

The best future outcome in this matter would probably be a group of people who dedicate their effort to making up to date images of things, and upload them as JPG right-away, so we can get rid of that conditional statement alltogether, and put something proper in place instead.

Edited by Ulviirala

Share this post


Link to post
Share on other sites

First off, I doubt I'll be messing with this anymore. Hopefully this suffices to explain what I was doing.

 

When I added that png convert category, I assumed people would take new screenshots in JPG format, crop then down and upload new ones. My mistake for not be specific.

 

 

While I agree that a category page is helpful, we could incorporate both if need be. Categories for utility, redlinks for convenience. I don't think it's more encouraging to forward everyone solely to a category page, instead of providing a redlink for something they care to lookup, and complete the article with an image. That's why I had left the category inclusion in. The category page itself doesn't forward you to the upload page, with the proper filename already preset. It's incomprehensible to me why you undid that too, since it's still showing in the bottom of the page. I was trying to meet on a middle ground but meh...
 

I undo a template:itembox entry because you made no effort explain why you changed things.

 

I understand now why the redlinks are good. I originally wanted to find a way to populate a page with all the missing "file:" red links, see post #3. I never figure out how and used links to pages where the image is used instead. It's a hassle to make a new page without a redlink to click on.

Share this post


Link to post
Share on other sites

Hm, I see. Oh well, it's a good thing we got to talk about it after all, no hard feelings. And I'm sure we can incorporate both in the template to keep going forward. I know you've done an absolute ton of dull typing work getting all the item articles to use the new template. I don't know why I was never around in this section of the forum.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this