• So i’m using new wp embed feature for post embedding(copy&paste link to post) and i wanted to remove featured image from it, since it was messing up whole embed output.

    Custom CSS classes does not react in any way with it, i’ve tried using:
    .wp-embed-featured-image img
    class with body, !important, single etc. and nothing happened.

    I removed few lines with div’s from embed-template.php in /wp-includes/ folder and it works, but there has to be better way to handle that. Function with filter or something will work too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    The fact you were able to style the image after removing some divs tells me that you just haven’t found the right selectors when the divs are intact. If you can provide a live link to an example embed someone might be able to offer a functional CSS selector to use.

    Otherwise, have you tried using your browser’s CSS tools? Usually by selecting the element you want to style, then adding a new rule for it results in a workable selector suggestion. If nothing else the CSS tools allow you to rapidly try different selectors until you hit one that works.

    I hope you realize that editing embed-template.php is not a viable solution. That file does not offer any useful filters, but the ones in embed.php could be useful. wp_get_attachment_image() has a filter for img tag attributes. You could use it to add a display:none; (or whatever) style attribute. The trick would be determining when the call is for a oEmbed featured image. You’d have to poke around in various globals and super-globals to see if there’s something.

    Or maybe you can create something to signal the embed state using one of the embed.php actions that can be checked by the ‘wp_get_attachment_image_attributes’ filter callback.

    Thread Starter Nikodemsky

    (@nikodemsky)

    At first i thought that too, but that was selectors from browser console and with live edit(on chrome), those selectors with few modifications worked. Also I checked those with wp-embed-template.css from /wp-includes/css/ folder.

    Solution i used is only temporary and i’m aware of that, also i’m not really fan of display:none; but it was the “fastest way”. I’ll check later for globals, maybe there will be something.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Dealing with wp-embed(4.4) output’ is closed to new replies.