Plugin Directory

Changeset 1593695


Ignore:
Timestamp:
02/11/2017 03:52:41 AM (9 years ago)
Author:
chrisy
Message:

Add the class attribute

  • Add class attribute to the shortcode to enable adding CSS classes to the img tag.
  • Make the test graph on the admin page have a transparent background.
  • Document emitjs attribute.
Location:
tfo-graphviz/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tfo-graphviz/trunk/readme.txt

    r1593680 r1593695  
    11=== TFO Graphviz ===
    22Contributors: chrisy
    3 Tags: graphviz, flirble, network, diagram, graph, dot, neato, twopi, circo, fdp, visualisation, visualization, layout, hierarchical
     3Tags: graphviz, flirble, network, diagram, graph, dot, neato, twopi, circo, fdp, visualisation, visualization, layout, hierarchical, graph, digraph, svg
    44Requires at least: 4.2.0
    55Tested up to: 4.7.2
     
    3030Where `<options>` is anything from this list. All are entirely optional:
    3131
     32* `class="*`&lt;css_class&gt;`*"`
     33
     34  Adds an extra CSS class name (or names) to the `img` tag of the rendered graph. This is in addition to the
     35  `graphviz` class that is already applied.
     36
     37* `emitjs="yes|no"`
     38
     39  Override the global setting that controls whether JavaScript is emitted as necessary. Typically this JavaScript is
     40  only produced when rendering SVG output and is intended to ensure SVG images work on most browsers. However this can
     41  sometimes be undesirable and thus this option gives some control over this.
     42
    3243* `height="*`&lt;image_height&gt;`*"`
    3344
     
    152163= Can I manipulate the rendered graph using CSS in my WordPress theme? =
    153164
    154 The `img` elements are tagged with '`class="graphviz"`'.
     165The `img` elements are tagged with '`class="graphviz"`'. Additionally, you can add `class="myclass"` to the shortcode to add additional classes to the `img` tag.
     166
     167= How can I make my graph have a transparent background?
     168
     169Add the tag `bgcolor="transparent"` to the root graph node. For example placing `graph [bgcolor="transparent"]` near the top like this:
     170
     171`
     172[graphviz]
     173digraph test {
     174  graph [bgcolor="transparent"]
     175  a1 -> a2 -> a3 -> a1;
     176}
     177[/graphviz]
    155178
    156179= Nothing is being rendered, maybe my DOT is broken? =
     
    244267== Changelog ==
    245268
     269= 1.16 =
     270* Add `class` attribute to the shortcode to enable adding CSS classes to the `img` tag.
     271* Make the test graph on the admin page have a transparent background.
     272* Document `emitjs` attribute.
     273
    246274= 1.15 =
    247275* Validate graph language and output format.
  • tfo-graphviz/trunk/tfo-graphviz-admin.php

    r1286738 r1593695  
    192192        @unlink(TFO_GRAPHVIZ_CONTENT_DIR . '/test.png');
    193193
    194         $graphviz_object = $this->graphviz('digraph test { a1 -> a2 -> a3 -> a1; }', array(
     194        $graphviz_object = $this->graphviz('digraph test { graph [bgcolor="transparent"] a1 -> a2 -> a3 -> a1; }', array(
    195195                'id' => 'test',
    196196                'lang' => 'dot',
     
    379379            <td class="syntax">
    380380            <p><?php printf( __( 'Use the shortcode syntax %s to insert graphs into your posts.', 'tfo-graphviz' ),
    381             '<code>[graphviz]digraph test { a1 -> a2 -> a3 -> a1; }[/graphviz]</code>'
     381            '<code>[graphviz]digraph test { graph [bgcolor="transparent"] a1 -> a2 -> a3 -> a1; }[/graphviz]</code>'
    382382        ); ?></p>
    383383                <p><?php _e( 'For more information, see the <a href="http://blog.flirble.org/projects/tfo-graphviz/">FAQ</a>' ); ?></p>
  • tfo-graphviz/trunk/tfo-graphviz-method.php

    r1286864 r1593695  
    4343    function __construct($dot, $atts) {
    4444        $this->dot  = (string) $dot;
    45         foreach (array('id', 'lang', 'simple', 'output', 'href', 'imap', 'title', 'size', 'dpi') as $att) {
     45        foreach (array('id', 'lang', 'simple', 'output', 'href', 'imap', 'title', 'size', 'dpi', 'emitjs', 'class') as $att) {
    4646            if (array_key_exists($att, $atts))
    4747                $this->$att = $atts[$att];
  • tfo-graphviz/trunk/tfo-graphviz.php

    r1593680 r1593695  
    176176                'dpi' => '',
    177177                'emitjs' => TFO_GRAPHVIZ_EMITJS,
     178                'class' => '',
    178179            ), $_atts);
    179180
     
    247248            }
    248249            $alt = esc_attr($gv->title);
    249             $ret = "<img src=\"$url\" class=\"graphviz\"";
     250            $ret = "<img src=\"$url\" class=\"graphviz";
     251            if (!empty($atts['class'])) $ret .= " ".esc_attr($atts['class']);
     252            $ret .= "\"";
    250253            if (!empty($alt)) $ret .= " alt=\"$alt\" title=\"$alt\"";
    251254            if (!empty($gv->imap)) $ret .= " usemap=\"#$gv->id\"";
Note: See TracChangeset for help on using the changeset viewer.