Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1176719

    Hi Team,

    I need an output of alt or title (text) below featured image in magzin- and blogelement (Listing).
    For an single post I can use this:

    .single-post .single-big a.lightbox-added:after {
        content: attr(title);
        font-size: 11px;
    }

    But the image links in linsting of magazin- or blogelemnt have no text (blogelement) or wrong text (magazinelemnt hast permalink as text in title) for the attributes. What can I do to fix this?

    Thank you and best regards
    Mike

    • This topic was modified 4 years, 10 months ago by Mike61.
    #1177085

    Hi Mike,

    You’ll need to override the Blog and Magazine Element.
    Please do the preparatory stuff that is written in our document: https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb
    After doing that, (from the Enfold theme, location: enfold > config-templatebuilder > avia-shortcodes folder) copy both magazine and postslider folder and paste it in the shortcodes folder of the child theme.
    Then in the child theme edit postslider.php and find this code (line 699 in Enfold 4.7.2):

    $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-".avia_post_slider::$slide."' class='slide-image' title=''>{$thumbnail}</a>" : '';

    replace with:

    $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-".avia_post_slider::$slide."' class='slide-image' title='{$title}'>{$thumbnail}</a>" : '';

    Then again, in the child theme edit magazine.php and find this code (line 1056 in Enfold 4.7.2):

    $titleAttr = "title='".__( 'Link to:','avia_framework' )." ".the_title_attribute(array('echo' => 0, 'post' => $entry->ID)) . "'";

    replace with:

    $titleAttr = "title='".the_title_attribute(array('echo' => 0, 'post' => $entry->ID)) . "'";

    Hope this helps.

    Best regards,
    Nikko

    #1177117

    Hi Nikko,
    thank you for your help! This will work but it is not what I mean – sorry, my fail.

    I need the title of the thumbnail (mediathek) as attr of the postlink:
    a.slide-image -> Blog element
    a.av-magazine-thumbnail-link -> Magazin element

    Hope you can help again.

    Thank you and best regards
    Mike

    • This reply was modified 4 years, 10 months ago by Mike61.
    #1177131

    Hi Mike,

    No worries, I see you want it applied to the image.
    Just remove the modification I suggested then in the child theme edit postslider.php and find this code (line 619 in Enfold 4.7.2):

    $thumbnail  = get_the_post_thumbnail( $the_id, $image_size );

    replace with:

    $thumbnail  = get_the_post_thumbnail( $the_id, $image_size, array('title' => $entry->post_title) );

    In magazine.php and find this code (line 1054 in Enfold 4.7.2):

    $image = get_the_post_thumbnail( $entry->ID, $this->atts['image_size'][$style] );

    replace with:

    $image = get_the_post_thumbnail( $entry->ID, $this->atts['image_size'][$style], array('title' => $entry->post_title) );

    Best regards,
    Nikko

    #1177138

    Hi Nikko,
    I am so sorry, but I don’t want applied the attr to the image, I want applied the title of the image (post thumbnail)
    as title to the postlink. So I can use…

    Blog element:

    .avia-content-slider a.slide-image:after {
        content: attr(title);
        font-size: 11px;
    }

    Magazin element:

    .av-magazine a.av-magazine-thumbnail-link:after {
        content: attr(title);
        font-size: 11px;
    }

    This will show the content of the image title (set in mediathek) for the link tag title of the post.
    I need this to show the image licensing below the image. (See link in private conent)

    Thank you again and best regards
    Mike

    #1177168

    Hi Mike,

    I’m not sure I understand it well.
    The codes I gave at the beginning apply to a.slide-image for Blog element and a.av-magazine-thumbnail-link for Magazine element.
    After reviewing our discussion you mentioned mediathek but I think I misunderstood that, can you give a screenshot for that?

    Best regards,
    Nikko

    #1177171

    Hi Nikko,

    I think my bad English is to blame.
    The code you gave me has the title of the post as output but I need the title of the image:
    the right title

    #1177382

    Hi Mike61,

    Thanks for providing the screenshot, it’s pretty clear to me now.
    Can we use data-title instead? so the code you should using for CSS is:

    content: attr(data-title);

    Edit postslider.php and find this code (line 699 in Enfold 4.7.2):

    $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-".avia_post_slider::$slide."' class='slide-image' title=''>{$thumbnail}</a>" : '';

    replace with:

    $image_alt = get_post_meta(get_post_thumbnail_id($the_id), '_wp_attachment_image_alt', TRUE);
    $output .= $thumbnail ? "<a href='{$link}' data-rel='slide-".avia_post_slider::$slide."' class='slide-image' title='' data-title='{$image_alt}'>{$thumbnail}</a>" : '';

    Edit magazine.php and find this code (line 1057 in Enfold 4.7.2):

    $title = "<a href='{$link}' {$titleAttr}>". apply_filters( 'avf_magazine_title', get_the_title( $entry->ID ), $entry ) . '</a>';

    replace with:

    $image_alt = get_post_meta(get_post_thumbnail_id($entry->ID), '_wp_attachment_image_alt', TRUE);
    $title = "<a href='{$link}' {$titleAttr} data-title='{$image_alt}'>". apply_filters( 'avf_magazine_title', get_the_title( $entry->ID ), $entry ) . '</a>';

    Hope this helps :)

    Best regards,
    Nikko

    #1177559

    Hi Nikko,

    great, this is what I needed :)
    Only one little thing is not correct, you need to change in magazin.php

    if($image) $output .="<a href='{$link}' {$titleAttr} class='av-magazine-thumbnail-link '>{$image}</a>";

    to

    if($image) $output .="<a href='{$link}' {$titleAttr} data-title='{$image_alt}' class='av-magazine-thumbnail-link '>{$image}</a>";

    for the right output.

    Thank you so mutch for your help, great service!
    Best regards
    Mike

    • This reply was modified 4 years, 10 months ago by Mike61.
    #1178041

    Hi,

    Awesome! Glad we could be of help. Please feel free to open a new thread if you need anything else.

    Have a nice day.

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Output alt or title below featured image in magzin- and blogelement’ is closed to new replies.