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

  • Home
  • SEARCH
  • 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 986387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:18:44+00:00 2026-05-16T05:18:44+00:00

I have people inserting video code to be displayed on my website. I want

  • 0

I have people inserting video code to be displayed on my website. I want to make sure those videos dimensions don’t go over 590 pixels in width.

So for example it they insert a video that’s 640 x 385 my script would figure out some new dimensions so that it is only 590 pixels in width (e.g: 590 x 366)… I’ve got all the maths and ratio stuff worked out, it’s just a matter of extracting the height and width from the and then replacing those with the new dimensions.

Here is a sample of some code I would need to get the dimensions of. There is also code below but once I figure how to work out the dimensions of the I can just duplicate the code for the

<object width="640" height="385">
    <param name="movie" value="http://www.youtube.com/v/ik6N1TLL2TI&hl=en_US&fs=1"></param>
    <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/ik6N1TLL2TI&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed>
</object>

I’ve got some code I was helped with in the past which adds a URL to links that don’t have a http:// in front of them. I tried to play with the code but couldn’t figure it out. If it helps, here’s the original code:

$content_text = preg_replace('%
    (<a\b[^>]*?href\s*+=\s*+)  # capture first chunk of A tag in group 1
    ("|\'|)                                   # capture HREF attribute delimiter in group 2
    (?!\w++://|/)                        # ensure URL has no scheme nor abs path
    ([^"\' >]++)                         # capture relative URI path in group 3
    \2                                        # match closing delimiter for HREF attribute
    %ix', '$1"' . SITEURL . '/$3"', $content_text);

Thanks for your help in advance!

  • 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-05-16T05:18:45+00:00Added an answer on May 16, 2026 at 5:18 am

    Probably will get raked through the coals for this, as you should use the HTML DOM parser in PHP. But here is the regex as an “alternate” method.

    preg_match('~<object.*(width|height)=(.*) (width|height)=(.*)(>|\s)~isU', $contents, $matches);
    if (!empty($matches)) {
        $dimensions[strtolower($matches[1])] = str_replace(array("'", '"'), '', $matches[2]);
        $dimensions[strtolower($matches[3])] = str_replace(array("'", '"'), '', $matches[4]);
    }
    

    The HTML Parser may be a wiser choice, but the above should grab the width and height no matter the quotes or the order and will place them in $dimensions['width'] and $dimensions['height'].

    Like I said, this is just an alternative example and the HTML Parser is probably the wiser way to go. Also the Regex could probably be written better as well but oh well. Hope it helps.

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

Sidebar

Related Questions

Some people have suggested that when doing an estimate one should make a lower
I have heard people state that Code Generators and T4 templates should not be
I've got a table that people have been inserting into getting the primary key
What memory leak detectors have people had a good experience with? Here is a
What solutions have people come up with to develop their web applications offline when
People have been developing own solutions to the following problems: Consistent messaging frameworks for
I have seen people say that it is bad form to use catch with
Lots of people have things that their systems do for them or for their
At work we have 4 people working together on a few different projects. For
I have used several different scripts that people have suggested for trying to parse

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.