Skip to content

Commit

Permalink
auto create alt tag for character component image
Browse files Browse the repository at this point in the history
  • Loading branch information
Bearded Avenger committed Aug 30, 2014
1 parent ef403d2 commit cd47e02
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion public/includes/components/component-character.php
Expand Up @@ -33,6 +33,10 @@ function aesop_character_shortcode($atts, $content = null) {
// wrapper float class
$float = $atts['align'] ? sprintf('aesop-component-align-%s', $atts['align']) : null;

// automatic alt tag
$auto_alt = $atts['img'] ? basename($atts['img']) : null;
$alt = $auto_alt ? preg_replace('/\\.[^.\\s]{3,4}$/', '', $auto_alt) : null;

// character wrap
ob_start();

Expand All @@ -52,7 +56,7 @@ function aesop_character_shortcode($atts, $content = null) {
<?php } ?>

<?php if ($atts['img']) {?>
<img class="aesop-character-avatar" src="<?php echo $atts['img'];?>" alt="">
<img class="aesop-character-avatar" src="<?php echo $atts['img'];?>" alt="<?php echo $alt;?>">
<?php } ?>

<?php if ($content) {?>
Expand Down

0 comments on commit cd47e02

Please sign in to comment.