Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide images from embed twitter timeline?

I tried everything. From CSS to jQuery and uncheck Auto-expand photos.

This is my embed code:

  <a class="twitter-timeline"
  href=""
  data-widget-id="" 
  data-chrome="noheader footer noborders noscrollbar transparent" 
  data-tweet-limit="5"
  data-link-color="#6AC829"
  data-border-color="#FFFFFF"
  lang="EN" data-theme="light"
  height="100"
  width="800" 
  data-screen-name=""
  data-show-replies="false"
  data-aria-polite="assertive">
  </a>

And this is my jQuery code:

 ! function(d, s, id) {
     var js, fjs = d.getElementsByTagName(s)[0],
         p = /^http:/.test(d.location) ? 'http' : 'https';
     if (!d.getElementById(id)) {
         js = d.createElement(s);
         js.id = id;
         js.src = p + "://platform.twitter.com/widgets.js";
         fjs.parentNode.insertBe fore(js, fjs);
     }
 }(document, "script", "twitter-wjs");

 window.setTimeout(function() {
     $(".twitter-timeline").contents().find(".e-entry-title").css("font-size", "12px");
     $(".twitter-timeline").contents().find(".inline-media").css("display", "none");
     $(".twitter-timeline").contents().find(".tweet").css("font-size", "12px");
     $(".twitter-timeline").contents().find(".p-name.customisable-highlight").css("font-size", "12px");
 }, 1000);
like image 910
Philip Avatar asked Dec 11 '25 05:12

Philip


1 Answers

I believe that I have a solution. I've tested in all major browsers. Sorry to be so late to this.

With the update on March 3rd this is again relevant.

https://blog.twitter.com/2016/a-new-improved-embedded-timeline

First step, wrap the timeline in a container such as a div. Next, add this jQuery to the footer or in a jQuery(document).ready();

jQuery('.twitter-block').on('DOMSubtreeModified propertychange',"#twitter-  widget-0", function() {
  jQuery(".twitter-timeline").contents().find(".timeline-Tweet-media").css("display", "none");
  jQuery(".twitter-block").css("height", "100%");
});

Target the container ie '.twitter-block', and the ID of the iframe "#twitter-widget-0". The second line hides the media (images/video) and the third resizes the iframe. This should work on page load, as well as for any dynamic updates made in the timeline.

like image 129
user3903555 Avatar answered Dec 12 '25 18:12

user3903555



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!