-
AuthorPosts
-
January 21, 2020 at 1:57 pm #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.
January 22, 2020 at 10:05 am #1177085Hi 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,
NikkoJanuary 22, 2020 at 11:17 am #1177117Hi 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 elementHope you can help again.
Thank you and best regards
Mike- This reply was modified 4 years, 10 months ago by Mike61.
January 22, 2020 at 11:44 am #1177131Hi 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,
NikkoJanuary 22, 2020 at 12:03 pm #1177138Hi 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
MikeJanuary 22, 2020 at 1:01 pm #1177168Hi 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,
NikkoJanuary 22, 2020 at 1:17 pm #1177171Hi 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:
January 23, 2020 at 5:09 am #1177382Hi 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,
NikkoJanuary 23, 2020 at 11:42 am #1177559Hi Nikko,
great, this is what I needed :)
Only one little thing is not correct, you need to change in magazin.phpif($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.
January 24, 2020 at 9:41 am #1178041 -
AuthorPosts
- The topic ‘Output alt or title below featured image in magzin- and blogelement’ is closed to new replies.