Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author victor_jonsson

    (@victor_jonsson)

    Crazy as it sounds but you can’t restrict the height of the images in arlima! The only way to get total control over the image dimensions is to hook into “arlima_article_image” and have your own logic for how image versions gets generated (read more here).

    We use the plugin “Scissors Continued” at our editorial offices to solve this problem. The plugin will automatically become integrated with Arlima once installed (here you can see it in action)

    Thread Starter Devotion

    (@devotion)

    Man, I’m really trying to figure out how to adjust it using that filter. Not getting there.

    I also meant the width, not the height. My bad. :/

    Plugin Author victor_jonsson

    (@victor_jonsson)

    hm… But the width should never be an issue. The width of the images will be resized to fit the width of your list. How do you display the list? Using a short-code or via the arlima meta box?

    Thread Starter Devotion

    (@devotion)

    I insert the list using shortcode and a PHP code widget. But the image doesn’t fit the width of the list. :S

    Image: http://s7.postimg.org/63lfthmmz/Sk_rmavbild_2013_04_19_kl_10_00_15.png

    Plugin Author victor_jonsson

    (@victor_jonsson)

    Are you setting the width of the arlima list in the short code?

    Thread Starter Devotion

    (@devotion)

    Yep. But I managed to solve it.

    Then another issue showed up. When inserting articles as half-width into a list, the image height is different for each article. Sure, I could use Scissors Continued to correct it, but shouldn’t there be a standard size for when displaying half-width, sort of?

    Thread Starter Devotion

    (@devotion)

    Plugin Author victor_jonsson

    (@victor_jonsson)

    Ok, great! What was the problem? How did you solve it?

    It does not take much time to edit the image in those cases that you have two aligned child articles. Use one of the predefined image versions (widescreen, cinema or square) and it will only take a couple of seconds…. bad answer I guess 🙂

    I you feel that you must automate the generation of images for child articles you would need to do something like this:

    add_filter('arlima_article_image', function($data) {
        $img = $data['article']['image_options'];
        if( $data['article']['parent'] > -1 ) {
            $width = round($data['width'] * 0.5);
            switch( $img['size'] ) {
                case 'half':
                    $width = round($width * 0.5);
                    break;
                case 'third':
                    $width = round($width * 0.33);
                    break;
                case 'fourth':
                    $width = round($width * 0.25);
                    break;
            }
    
            // height of the image
            $height = round($width * 0.5);
    
            // Generate image
            // todo: save file in attachment meta!!
            $file = get_attached_file($img['attach_id']);
            $image_version = image_make_intermediate_size($file, $width, $height, true);
            $url = dirname($data['source']) .'/'. $image_version['file'];
    
            // Change image to the one we created
            $data['content'] = sprintf(
                            '<img src="%s" width="%d" height="%d" alt="%s"/>',
                            $url,
                            $width,
                            $height,
                            $data['article']['title']
                        );
        }
        return $data;
    });

    Note that this code generates the image every time, todo added in code…

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Image size in list?’ is closed to new replies.