Hey,
Is there a nice way to obtain the first image on a page?
My current solution works, but is not very nice: * get the images on the page via api.php?action=query&prop=images&titles=pagename * get the page contest via index.php?title=pagename&action=raw * find the first occurrence of one of the image names obtained in the API request
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Wed, Nov 2, 2011 at 11:49 AM, Jeroen De Dauw jeroendedauw@gmail.comwrote:
Hey,
Is there a nice way to obtain the first image on a page?
My current solution works, but is not very nice:
- get the images on the page via
api.php?action=query&prop=images&titles=pagename
- get the page contest via index.php?title=pagename&action=raw
- find the first occurrence of one of the image names obtained in the API
request
The question is what to call "first". First images on many pages are icons from maintenance templates, you know:) Or the first image in page text is displayed at the bottom of the page with CSS. Or it may be generated by template and not be visible in wikitext.
Hey,
The first "significant" image on the page, ie one that can be used to "represent" the page. I realize you can not do this fully accurate without having some additional s*mantics, but if it works most of the time, such as is the case with my approach, it's good enough.
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
This depends on what you consider a first picture of a page, wheter it's a picture not transluded from a template and also if it's a picture on top of the page (layout) or first picture in wikipage source, in the case that it's first picture in wikisource, what you need to call api.php?action=query&prop=images&titles=pagename for?
On Wed, Nov 2, 2011 at 9:38 AM, K. Peachey p858snake@gmail.com wrote:
Have a look at how the popups gadget does it.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org