ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

getting image width and height only relative URLs work :-(

July 19, 2010 6:50pm

Subscribe [4]
  • #1 / Jul 19, 2010 6:50pm

    Paradise

    84 posts

    Hi,

    i don’t want do make a field for width and height and put it by hand in there for my article images.
    So i’m trying do do it with getimagesize. The problem is that the filemanager puts the whole URL in there and that gives me an 404 on the image.

    So this works:

    <a href="http://mydom.de/uploads/img_1/test.jpg">http://mydom.de/uploads/img_1/test.jpg</a>

    This not:

    <a href="http://mydom.de/uploads/img_1/test.jpg">http://mydom.de/uploads/img_1/test.jpg</a>

    and is the output of:

    {m_article_img}


    any ideas?


    Edit:
    Can’t post my code - it gets cut…

  • #2 / Jul 20, 2010 6:16am

    tidy

    196 posts

    There is an EE1 plugin which gets image dimensions which might help you:
    http://devot-ee.com/add-ons/image-dimensions/

    Or you could always just leave out the width and height attributes in the img tag 😊

    Normally I want to force uploaded images to be certain dimensions, or at least put a max width or height to avoid messing up layouts. The image sizer plugin is a life saver for that http://devot-ee.com/add-ons/image-sizer/ I guess that would also be an alternative for you here, because if the image is smaller than the dimensions you specify using image sizer it will keep its own dimensions and they will appear in the HTML.

    Hope this helps

  • #3 / Jul 21, 2010 2:16am

    Paradise

    84 posts

    Sorry forgot to say i’m on EE2. I use ED Imageresizer, but this are pictures i use in the content i publish and there is no need for resizing them. And i’m not a friend of leaving out the width and height attributes in the img tag 😊

  • #4 / Jul 21, 2010 6:15am

    Steven Grant

    894 posts

    Why not use Matrix and have content images and use replace as per this thread http://ellislab.com/forums/viewthread/139892/#690174

  • #5 / Jul 21, 2010 7:42am

    Paradise

    84 posts

    @Steven, that is exactly what i’m doing. If i would put the images in my content via “<img

  • #6 / Jul 21, 2010 8:17am

    Steven Grant

    894 posts

    Won’t Lumis image sizer do your height & width?

    # if you use only width or only height the image will be scaled to match that width or height proportionately
    # if you use auto, The image will be scaled to the longest side proportionately.

  • #7 / Jul 21, 2010 9:11am

    Paradise

    84 posts

    Damn, the half post is gone :-(

    Ok, again:
    that is exactly what i’m doing. If i would put the images in my content via img tag i also could put in height and width. But with the Matrix/Transplant solution i have only image-1, image-2 ans so on. I don’t need to resize my images if i make an entry, so there is no need for Imageresizer. So i have an field for width and height in Matrix who i fill out by hand.

    @Steven, your avatar reminds me of Space Quest *lol

  • #8 / Jul 21, 2010 9:22am

    Steven Grant

    894 posts

    Yeah you could but you’d need to add the height and width tags manually? If you use image resizer, and set the height and width to auto then it won’t actually resize, it’ll just add your image dimensions?

  • #9 / Jul 21, 2010 5:50pm

    Paradise

    84 posts

    Ok, the problem is somewhere else.

    {m_article_images}
       {exp:nsm_transplant:content id="image-{row_count}"}
      
       {exp:ed_imageresizer image="{m_article_img}" maxWidth="1000" maxHeight="1000" class="{m_article_img_allign}" alt="{m_article_img_title}" title="{m_article_img_title}"}
    
       {/exp:nsm_transplant:content}
    
    {/m_article_images}

    works.
    But:

    {m_article_images}
       {exp:nsm_transplant:content id="image-{row_count}"}
      
       {exp:ed_imageresizer image="{m_article_img_small}" maxWidth="1000" maxHeight="1000" class="{m_article_img_allign}" alt="{m_article_img_title}" title="{m_article_img_title}"}
    
       {/exp:nsm_transplant:content}
    
    {/m_article_images}

    gives me:

    Severity: Notice
    Message: getimagesize() [function.getimagesize]: Read error!
    
    Severity: Warning
    Message: Cannot modify header information - headers already sent by (output started at /var/www/mydomain/htdocs/system/codeigniter/system/core/Exceptions.php:166)
    Filename: core/Common.php
    Line Number: 428

    {m_article_img} is in column 1 and {m_article_img_small} in column 2 of the rows.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases