Skip to content

Instantly share code, notes, and snippets.

@zhukovec
Created February 11, 2020 08:03
Show Gist options
  • Save zhukovec/c6705b8d906260a1f7046f1a766c923e to your computer and use it in GitHub Desktop.
Save zhukovec/c6705b8d906260a1f7046f1a766c923e to your computer and use it in GitHub Desktop.

Revisions

  1. zhukovec created this gist Feb 11, 2020.
    12 changes: 12 additions & 0 deletions alt-image-woo
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <?
    add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
    function change_attachement_image_attributes($attr, $attachment) {
    global $post;
    if ($post->post_type == 'product') {
    $title = $post->post_title;
    static $num = 0;
    $num++;
    $attr['alt'] = sprintf("Фото %d - %s.",$num,$title);
    }
    return $attr;
    }