Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9057089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:21:53+00:00 2026-06-16T14:21:53+00:00

I have been searching all day for a solution to this and have read

  • 0

I have been searching all day for a solution to this and have read many articles on image resizing and DOM node searching and WordPress functions and any other possible way for this to be done.

Heres the scenario…

I am creating a custom theme for WordPress for a client. This is a newspaper site and requires the functionality that it auto-resizes the pictures proportionally to fit within a certain box on the page. Normally I would just set width:SomeWidthin CSS but I don’t have any way to ID the img.

My index page is a framework and the wordpress engine loads the content. This means that until it is displayed to the user I don’t have any control of the attributes on the image. (Yes we could manually size every picture, but my client doesn’t want to have to do that, and she also wants it to be the original size on the single page.

Here is one of boxes:

<div class="box-center">
        <h1>Music 101</h1>
        <div class="box-inner-center">
            <ul>
                <?php
                    global $post;
                    $args = array('numberposts'=>1,'category'=>get_cat_ID('Music 101'));
                    $myposts=get_posts($args);
                    foreach($myposts as $post) : setup_postdata($post); ?>
                        <li><?php the_content(); ?></li>
                    <?php endforeach; ?>
            </ul>
            <a class="more" href="<?php echo esc_url(get_category_link(get_cat_ID('Music 101'))); ?>">More Music 101 >></a>
        </div>
    </div>

After the page loads this is what comes out:

<div class="box-center">
    <h1>Music 101</h1>
        <div class="box-inner-center">
            <ul>
                <li>
                    <p>
                        <a href="http://***?attachment_id=150" rel="attachment wp-att-150">
                            <img class="alignnone  wp-image-150" alt="Venice Symphony Orchestra" src="http://***/Venice-Symphony-Orchestra.jpg" width="960" height="640">
                        </a>
                    </p>
                    <p><span style="color: #000000;"><b><i>Some sample text.</i></b></span></p>
                    <p><span style="color: #000000;"><b>By Someone</b></span></p>
                    <p><span style="color: #000000;">Some quote and more content</span></p>
                    <p><span style="color: #000000;"><a href="http://***?p=141#more-141" class="more-link">(more…)</a></span></p>
                </li>
            </ul>
            <a class="more" href="http://***/?cat=20">More Music 101 &gt;&gt;</a>
        </div>
    </div>

I have tried using document.getElementById("box-center").childNodes and document.getElementByTagName("img") and then for loop through the results and set the properties there, but the above lines return no results somehow.

I would prefer not to use JQuery or any additional libraries if possible.

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:21:55+00:00Added an answer on June 16, 2026 at 2:21 pm

    I don’t see any reason why you can’t use css. I would suggest something like this:

    .box-center .box-inner-center img {
        width:150px; /* or whatever */
        height:auto; /* overrides the set HTML height*/
    }
    

    This will override the width and height attributes on the image itself and you can even be more specific if necessary: .box-center .box-inner-center ul p > a img or whatever you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been searching all day and can't find a solution to this... I have
Ok, I've been searching for all day to this problem. I have a loop,
I have been searching for a solution to this and so far found nothing
I've been searching all day and found several similar issues, but none have resolved
I've been searching all day for an answer to this, so hopefully someone can
I have been searching for this. All the related Java APIs are worked on
I have been searching around the web all day for the best way to
Hey, I have been searching all over for a solution to injecting into action
I have been searching all over stackoverflow and Google for a solution to my
I have been searching all day but unable to find any answers - I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.