how get specific image size, from field, via php?

More
11 years 11 months ago #31225 by pabro
Hi,

how can i get an image, defined in custom image field, in template (item.php) via php?

I know, with
Code:
$this->fields['imagefield']->display
i get the resized image. But how can i get a specific size like small, big, medium, and original resource (with php)?

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #31233 by micker
ggpdk solution
Code:
the image URLs are in the variables: ...->display_small_src ...->display_medium_src ...->display_large_src
regards

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #31264 by pabro
Merci!!

Is there also a variable for the original image path (without resize)?

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #31270 by ggppdk
This is somewhat complex to work in all cases, you can easily get original image name but not full path

we have 3 cases, DB-mode, folder-mode, default image, i think we could add a property to the image field

e.g. in category_items.php file:

Code:
$img_field_name = 'field11'; $img_field = & $items[$i]->fields[$img_field_name]; if ( !empty($img_field->value[0]) ) { $value = unserialize($img_field->value[0]); if ( !empty($img_field->value[0]['is_default_value'] ) ) { $original_path = JPATH_BASE .DS. $value['default_image']; } else if ($img_field->parameters->get('image_source') && ) { $original_path = JPATH_BASE .DS. $img_field->parameters->get('dir'); $original_path .= DS. 'item_'.$items[$i]->id.'_field_'.$img_field->id; $original_path .= DS. 'original' .DS. $value['originalname']; } else { $original_path = COM_FLEXICONTENT_FILEPATH .DS. $value['originalname']; } $original_path = JPath::clean( $original_path ); } else { $original_path = ''; }

NOTE above is folder path NOT url path


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #31272 by pabro
the original name would be enough for me, the path is not variabel and can i write in code :)

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #31273 by ggppdk
Name would be:
Code:
$img_field_name = 'field11'; $img_field_value = @$items[$i]->fields[$img_field_name]->value[0]; if ($img_field_value) { $originalname= $img_field_value['originalname']; // output something }


Also this should give original file URL:
Code:
$img_field_name = 'field11'; $img_field = & $items[$i]->fields[$img_field_name]; if ( !empty($img_field->value[0]) ) { $value = unserialize($img_field->value[0]); if ( !empty($img_field->value[0]['is_default_value'] ) ) { $original_url = JURI::root(). .'/'. $value['default_image']; } else if ($img_field->parameters->get('image_source') && ) { $original_url = JURI::root().'/'. $img_field->parameters->get('dir'); $original_url .= '/'. 'item_'.$items[$i]->id.'_field_'.$img_field->id; $original_url .= '/'. 'original' .'/'. $value['originalname']; } else { $original_url = JURI::root().'/'.$params->get('file_path', 'components/com_flexicontent/uploads') .'/'. $value['originalname']; } } else { $original_url = ''; }


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.420 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline