• I am trying to get my page’s images to scale with the slider container they’re inside of. We’re using the hotec theme with royal sliders and I added a filter to the functions.php file in hopes that this would bring me content responsive images.

    <?php
    add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
    add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
    function remove_thumbnail_dimensions( $html ) {
    $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    return $html; }
    ?>

    Do I need to change anything after this to get the images to respond?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Could you not just use a responsive slide plugin? Plus if you are modifying your main theme files those will just be overwritten on update.

    Thread Starter Kinoko_Tamashi

    (@kinoko_tamashi)

    My understanding is that I should be able to insert that snippet into functions.php to remove the width attribute from the images in essence making them content responsive. The problem seems to be that wp automatically states a size attribute for each image which causes it not to respond when the browser window is resized. A plugin could be another option, but I don’t see why I can’t modify the current one for it to be responsive. The shear number of different style sheets is befuddling as well.

    Again, any changes you make to the theme files will be overwritten when the theme gets updated, so you could do one of two things:
    1. Use a responsive slider plugin
    2. Create a child theme or use a built in custom CSS editor to overwrite things so that all the widths are in percent instead of pixels. That is my default the percent of the available width inside the containing element. So if the containing element shrinks then the element (in this case a images) inside shrinks with it.

    Thread Starter Kinoko_Tamashi

    (@kinoko_tamashi)

    I believe there is a css sheet as a child theme already called custom.css? Not entirely sure though, I will look into building my own child theme if not. Thanks for the help :3

    No problem. If you have troubles link me the website so I can take a look.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Content Responsive Images’ is closed to new replies.