Skip to content

Commit

Permalink
Fix alt tag issue #1883
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Mar 1, 2018
1 parent b0ad83e commit 5ffe32e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* Vendor library updated to latest
* Improved `Session` initialization
1. [](#bugfix)
* Fixed issue with remote PHP version determination for Grav updates
* Fixed issue with image alt tag always getting empted out unless set in markdown
* Fixed issue with remote PHP version determination for Grav updates [#1883](https://github.com/getgrav/grav/issues/1883)

# v1.4.0-rc.2
## 02/15/2018
Expand Down
9 changes: 5 additions & 4 deletions system/src/Grav/Common/Helpers/Excerpts.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,12 @@ public static function processImageExcerpt(array $excerpt, Page $page)

// Process operations
$medium = static::processMediaActions($medium, $url_parts);
$element_excerpt = $excerpt['element']['attributes'];

$alt = isset($excerpt['element']['attributes']['alt']) ? $excerpt['element']['attributes']['alt'] : '';
$title = isset($excerpt['element']['attributes']['title']) ? $excerpt['element']['attributes']['title'] : '';
$class = isset($excerpt['element']['attributes']['class']) ? $excerpt['element']['attributes']['class'] : '';
$id = isset($excerpt['element']['attributes']['id']) ? $excerpt['element']['attributes']['id'] : '';
$alt = isset($element_excerpt['alt']) ? $element_excerpt['alt'] : '';
$title = isset($element_excerpt['title']) ? $element_excerpt['title'] : '';
$class = isset($element_excerpt['class']) ? $element_excerpt['class'] : '';
$id = isset($element_excerpt['id']) ? $element_excerpt['id'] : '';

$excerpt['element'] = $medium->parsedownElement($title, $alt, $class, $id, true);

Expand Down
4 changes: 3 additions & 1 deletion system/src/Grav/Common/Page/Medium/Medium.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,14 @@ public function parsedownElement($title = null, $alt = null, $class = null, $id
}

if (empty($attributes['alt'])) {
if (!empty($alt) || $alt === '') {
if (!empty($alt)) {
$attributes['alt'] = $alt;
} elseif (!empty($this->items['alt'])) {
$attributes['alt'] = $this->items['alt'];
} elseif (!empty($this->items['alt_text'])) {
$attributes['alt'] = $this->items['alt_text'];
} else {
$attributes['alt'] = '';
}
}

Expand Down

0 comments on commit 5ffe32e

Please sign in to comment.