Last modified: 2012-08-28 09:58:09 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T37647, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 35647 - Retrieve the first image used on a page
Retrieve the first image used on a page
Status: RESOLVED WORKSFORME
Product: MediaWiki
Classification: Unclassified
File management (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-02 16:49 UTC by Subfader
Modified: 2012-08-28 09:58 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Subfader 2012-04-02 16:49:28 UTC
I can retrieve all images used on a page but not the first.

[[File:Foo.jpg]]

Text

[[File:Bar.jpg]]

How can I retrieve Foo.jpg?
Comment 1 Sam Reed (reedy) 2012-04-02 16:52:24 UTC
I don't think it's stored in way you can find out..

For example on my dev wiki, it seems they are returned in alphabetical order

      <page pageid="1" ns="0" title="Main Page">
        <images>
          <im ns="6" title="File:Blah.png" />
          <im ns="6" title="File:Sommeimagge.png" />




mysql> select * from mw_imagelinks;
+---------+------------------------------------------------+
| il_from | il_to                                          |
+---------+------------------------------------------------+
|       1 | Blah.png                                       |
|       1 | Sommeimagge.png                                |



You'd probably have to regex scrape the page text...
Comment 2 Bawolff (Brian Wolff) 2012-04-02 20:19:00 UTC
>You'd probably have to regex scrape the page text...

Doing ?action=parse and looking at the image links output might be in order of appearance in page (since the results come the parse).

Most js tools that do this (for example [[n:WN:ML]] just regex scape it as far as I know.

-----
I do not think there is a compelling reason to go to the trouble of storing this in the db and providing specific mechanisms in the api to extract it.
Comment 3 Subfader 2012-04-06 16:49:23 UTC
How can I retrieve the source text without JS in an extension and without the API?
Comment 4 Bryan Tong Minh 2012-04-06 17:07:11 UTC
Construct a new Revision object, and look at the getText functions.
Comment 5 Subfader 2012-04-06 17:30:17 UTC
Cheers!
$rev = Revision::newFromTitle( $title );
$text = $rev->getText();

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links