[PATCH 3/8] convert wikimedia img src to thumbnail url
Signed-off-by: klObs <jw@klobs.de>
This commit is contained in:
parent
952ce2f9ca
commit
feb4741da2
|
@ -57,7 +57,37 @@
|
||||||
<xsl:variable name="path">
|
<xsl:variable name="path">
|
||||||
<xsl:call-template name="normalize-path">
|
<xsl:call-template name="normalize-path">
|
||||||
<xsl:with-param name="path">
|
<xsl:with-param name="path">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains(string(.), '://')">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains(string(.), 'wikimedia.org')">
|
||||||
|
<xsl:variable name="filename">
|
||||||
|
<xsl:value-of select="string(str:tokenize(string(.),'/')[last()])"/>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:variable name="hash">
|
||||||
|
<xsl:value-of select="concat(str:tokenize(string(.),'/')[position()=last()-2],'/',str:tokenize(string(.),'/')[position()=last()-1],'/')"/>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:variable name="validfilename">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="contains($filename, '.svg') and string-length(substring-after($filename, '.svg'))=0">
|
||||||
|
<xsl:value-of select="concat($filename, '.png')"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="$filename"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:variable>
|
||||||
|
<xsl:value-of select="concat(substring-before(string(.),'commons/'),'commons/thumb/',$hash,$filename,'/600px-',$validfilename)"/>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
<xsl:value-of select="string(.)"/>
|
<xsl:value-of select="string(.)"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<xsl:value-of select="string(.)"/>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
</xsl:with-param>
|
</xsl:with-param>
|
||||||
</xsl:call-template>
|
</xsl:call-template>
|
||||||
</xsl:variable>
|
</xsl:variable>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user