• Resolved Ismail

    (@elhardoum)


    hello everyone.
    i am creating my own theme and i am trying to set a max-width and max-height for post thumbnails in functions.php
    i found this php tag:
    set_post_thumbnail_size(80, 80, false);

    but i want to use max measures not fixed ones..
    is there any way to include CSS inside that php tag ?
    i already have this in my css file :

    .post-thumbnail, .attachment-post-thumbnail {
        max-height: 300px;
        max-width: 540px;
    }

    but since it is a post thumbnail they add html height="" width=""

    any help is kindly appreciated !
    ^ sam

Viewing 5 replies - 1 through 5 (of 5 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    reset it with CSS: “width: auto; height auto”

    Thread Starter Ismail

    (@elhardoum)

    thank you andrew for the quick reply.
    i did that and it still adds this :
    <img width="1920" height="1200" src="//" class="attachment-post-thumbnail wp-post-image" alt="//">
    i want to use CSS only ( class="attachment-post-thumbnail" ), so how can i get rid of width="1920" height="1200"
    thank you sir ??

    Thread Starter Ismail

    (@elhardoum)

    thank you sir.. i figured out a solution.. thanks for assisting me ??

    @samuel Elh

    Hi, I am facing the exact same problem.
    Would appreciate it if you could share your solution.

    Best,
    TheTree.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The exact solution was this:

    .post-thumbnail,
    .attachment-post-thumbnail {
        width: auto;
        height auto;
    }

    If you’re not creating your own theme then I don’t think you have the exact problem.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘include css in php ( max-height, max-width for post thumbnail )’ is closed to new replies.