Dve velikosti obrazku v html

Petr Neuman kajman na gmail.com
Úterý Červen 13 18:03:22 CEST 2006


2006/5/26, Jirka Kosek <jirka na kosek.cz>:
> Petr Neuman wrote:
> > Dá se nějak snadno nastylovat pro html obrázek tak, aby byl zmenšený a
> > byl odkazem na velký uvedený v docbooku?
>
> Styly to samy od sebe neumí, ale šlo by to celkem jednoduše
> doprogramovat v XSLT.

Po delší době jsem si na to našel čas a zkusil to nějak zbastlit...

<xsl:template match="mediaobject|mediaobjectco">

  <xsl:variable name="olist" select="imageobject|imageobjectco
                     |videoobject|audioobject
                     |textobject"/>

  <xsl:variable name="object.index">
    <xsl:call-template name="select.mediaobject.index">
      <xsl:with-param name="olist" select="$olist"/>
      <xsl:with-param name="count" select="1"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:variable name="object" select="$olist[position() = $object.index]"/>

  <xsl:variable name="align">
    <xsl:value-of select="$object/imagedata[@align][1]/@align"/>
  </xsl:variable>

  <xsl:variable name="role">
    <xsl:value-of select="$object/imagedata[@role][1]/@role"/>
  </xsl:variable>

 <xsl:variable name="nextimg">
    <xsl:value-of
select="$object/following-sibling::*[1]/imagedata[@fileref][1]/@fileref"/>
  </xsl:variable>

  <div class="{name(.)}">
    <xsl:if test="$align != '' ">
      <xsl:attribute name="align">
        <xsl:value-of select="$align"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:if test="@id">
      <a name="{@id}"/>
    </xsl:if>
    <xsl:choose>
    <xsl:when test="$nextimg != '' and $role='nahled'">
    <a href="{$img.src.path}{$nextimg}" onclick="return
!window.open(this.href)" class="bigimg">
    <xsl:apply-templates select="$object"/>
    </a>
    </xsl:when>
   <xsl:otherwise>
    <xsl:apply-templates select="$object"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="caption"/>
  </div>
</xsl:template>

Kdy to pro následující kód

 <mediaobject>
  <imageobject role="html">
   <imagedata role="nahled" fileref="schema_male.gif"/>
  </imageobject>
  <imageobject role="fo">
   <imagedata fileref="schema_velke.gif"/>
  </imageobject>
 </mediaobject>

Použije malý obrázek, co odkazuje na ten další.

Asi to není zrovna optimální, ale nám to stačí a třeba to někomu pomůže.


-- 
       Kajman alias "Petr Neuman"


Další informace o konferenci Docbook