• jakry001

    (@jakry001)


    Hi there,

    I insert a lot of youtube clips, soundcloud clips and images into posts.

    Is it possible to make some modifications so that everytime I insert/embed something it will automatically be formatted a certain way, rather than having to manually format it each time?

    I have set the style and formatting of ‘pre’ (preformatted) i would like to use in style.css. This means I have to manually add the ‘pre’ tags to everything I embed and insert. Its not such a great pain, but I do insert a lot of items, so automating this process would be excellent.

    Thank you ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter jakry001

    (@jakry001)

    anyone have any idea?

    Joseph

    (@jpe24524)

    I’m confused. You insert videos and images but you also wrap them in <pre> tags?

    It’s usually used for displaying code blocks as it preserve spaces and line breaks.

    Thread Starter jakry001

    (@jakry001)

    Once I have it hosted it will be easier to show what I mean. Atm it’s locally hosted, so I try to describe as accurately as I can.

    I know it sounds strange, but all I’ve done is edited the style of <pre>, so using these tags will make my embedded objects and images appear a certain way in post.

    It’s a long story, but Alchymyth showed me how to style all contents of a post <p> automatically. The solution worked:

    add_filter('the_content','hightlight_the_paragraphs');
    function hightlight_the_paragraphs($output) {
    if(!is_page()) :
    $output = str_replace('<p>','<p><span style="background: yellow; padding: 3px;">',$output);
    $output = str_replace('</p>','</span></p>',$output);
    endif;
    return $output;
    }

    All post content would be styled, style="background: yellow; padding: 3px;".

    The problem, however, is this solution would also affect embedded objects and images. It would leave an ugly bottom border to them. In order to remove this bottom border, I would wrap these objects in <pre> tags which I styled to my taste. Therefore, everytime I embed or insert something I need to do this process manually. I was hoping for an automated solution similar to the one Alchymyth came up with.

    I hope you understand what I mean haha…

    Thank you anyway ??

    Joseph

    (@jpe24524)

    Ok, I see what you mean.

    First of all, I would just like to comment on the paragraph styling method. Why do all that when it can be done with external CSS? A simple rule like

    .entry p {
    	background: yellow;
    	padding: 3px;
    }

    would have done the trick. You might not have .entry but should have selectors you could point to to only style the post paragraphs.

    Back to your question, you could use the filter with regular expression to add the tags. I’m not really good at regex so I can’t provide much help on that.

    If you don’t mind a semi-automatic method, you can add quicktags to your post editor. See https://perishablepress.com/press/2006/09/18/customize-wordpress-quicktags/

    Thread Starter jakry001

    (@jakry001)

    hmmm, haha i got no idea, that seems like a very good and obvious solution.

    thanks for your help ?? i think im just going to change it manually.

    thanaks again

    EnglishMike

    (@stringfold)

    You might find the Embedder plugin helpful if you do a lot of embedding:

    https://moztools.com/2010/11/23/stupid-embedder-tricks-2-youtube-video-embeds/

    As the article shows, you can add either add styles to the embed, or wrap them with a div or span and give it another class name.

    You can also define embed attributes that allow you to set different values every time you embed a video, if you like.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Twenty ten: anything embedded in a post automatically formatted a certain way?’ is closed to new replies.