Custom Attributes image
Permalink 2 users found helpful
Hello community.
I have created several custom atributes for a page including image/file one.
Using page list block i can output this attributes apart from the image one.
Is there a way that i can output the image that is set in that attribute?
I have created several custom atributes for a page including image/file one.
Using page list block i can output this attributes apart from the image one.
Is there a way that i can output the image that is set in that attribute?
Yes it did, thank you for your response.
Sorry.. but can you give me all of the code for this.. I tried to figure it out but could not..
Load image helper
$im = Loader::helper('image');
then to get you image
$image= $cobj->getCollectionAttributeValue('your_image_atribute');
<?php if (is_object($image)) {$im->output($image);}?>
$im = Loader::helper('image');
then to get you image
$image= $cobj->getCollectionAttributeValue('your_image_atribute');
<?php if (is_object($image)) {$im->output($image);}?>
Sorry.. I'm being really literal when I say all the code. I'm new to PHP and I'm pretty sure you're assuming I know to put something in front of that or surrounding that.. because you can't just start something with a $ sign.
Here's my main body tag...
<?php
$a = new Area('Main');
$a->display($c);
?>
If I want to have an image resized, embedded, and right justified on the page like this..http://demo.getcontrolfreak.com/services/....
What would I put in front of it exactly..
IE:
<CODE? size="400" align="right"> <?php
$a = new Area('Main');
$a->display($c);
?>
Sorry to be a pain.. This is the only remaining question I have with Concrete5 and it would save me a ton of time setting up pages..
Here's my main body tag...
<?php
$a = new Area('Main');
$a->display($c);
?>
If I want to have an image resized, embedded, and right justified on the page like this..http://demo.getcontrolfreak.com/services/....
What would I put in front of it exactly..
IE:
<CODE? size="400" align="right"> <?php
$a = new Area('Main');
$a->display($c);
?>
Sorry to be a pain.. This is the only remaining question I have with Concrete5 and it would save me a ton of time setting up pages..
I thought you where hardcoding this.
If you are inserting a image with image block you can align the image easily you have the option to define left, center or right.
Other alternative would be to wrap you main area in lets say
If you are inserting a image with image block you can align the image easily you have the option to define left, center or right.
Other alternative would be to wrap you main area in lets say
<div class="main"></div> then in your css file you can do #main IMG{text-align:left, center, right}
No.. That's not what I'm doing. I am trying to hard code the attribute itself. I'm simply trying to make it so that users can attach a thumbnail attribute image and an larger page image attribute when setting up a new page all at the same time.. Not hard coded..
I know you can do it manually with an image block.. but I thought that was something that could be automatically done with an attribute?
I know you can do it manually with an image block.. but I thought that was something that could be automatically done with an attribute?
Take a look at this.
Ok.. That worked! Thank you.. But how do I right justify the image.. and have it automatically re-size to a certain width.. like say 400px wide?
This is how the page shows up now with your code..
http://demo.getcontrolfreak.com/about-us/...
Also.. Wasn't sure if I needed to add this to my view.php page.. or if I could just add it to any page I wanted..
Thank you soooo much.. I'm just about there.
This is how the page shows up now with your code..
http://demo.getcontrolfreak.com/about-us/...
Also.. Wasn't sure if I needed to add this to my view.php page.. or if I could just add it to any page I wanted..
Thank you soooo much.. I'm just about there.
> But how do I right justify the image.. and have it automatically
> re-size to a certain width.. like say 400px wide?
Perhaps I'm not understanding the issue entirely, but the layout (including justification) is generally accomplished through styles, be they inline, embedded, or externally referenced CSS style sheets - the latter being preferable because they're easier to maintain and keep structure and presentation separate.
As for image dimensions, it's of course best to have the image sized to the appropriate dimensions before it's served to the browser (for bandwidth and performance reasons). That said, you can specify just a single dimension (either width or height) in the <img> tag itself (or through CSS for that matter), and the other dimension will be determined automatically, thereby maintaining the aspect ratio of the image.
(BTW, I don't see any image at all on the page you referenced.)
-Steve
> re-size to a certain width.. like say 400px wide?
Perhaps I'm not understanding the issue entirely, but the layout (including justification) is generally accomplished through styles, be they inline, embedded, or externally referenced CSS style sheets - the latter being preferable because they're easier to maintain and keep structure and presentation separate.
As for image dimensions, it's of course best to have the image sized to the appropriate dimensions before it's served to the browser (for bandwidth and performance reasons). That said, you can specify just a single dimension (either width or height) in the <img> tag itself (or through CSS for that matter), and the other dimension will be determined automatically, thereby maintaining the aspect ratio of the image.
(BTW, I don't see any image at all on the page you referenced.)
-Steve
I'm looking for just the same functionality as the thumbnail attributes have. Simply by attaching a thumbnail attribute the image gets automatically re-sized to whatever width you set (IE: 100px wide)..
I suppose I could right justify the whole container as opposed to simply putting it in the image tag.. but I'm not sure if that would accomplish having the text on the page wrap around the image.
I got it to work by wrapping it in an image tag.. but the image width not only didn't resize the image.. but it's not even restricting the image size.. I know my clients will attach gigantic images and blow out the page if I give them this ability without at least constraining the image width.. Any idea why the image width in this tag isn't working? <img width="100" src="<?php if (is_object($image)) {$im->output($image);}?>" align="right" />.
Here's my page with the current code.. http://demo.getcontrolfreak.com/services....
I suppose I could right justify the whole container as opposed to simply putting it in the image tag.. but I'm not sure if that would accomplish having the text on the page wrap around the image.
I got it to work by wrapping it in an image tag.. but the image width not only didn't resize the image.. but it's not even restricting the image size.. I know my clients will attach gigantic images and blow out the page if I give them this ability without at least constraining the image width.. Any idea why the image width in this tag isn't working? <img width="100" src="<?php if (is_object($image)) {$im->output($image);}?>" align="right" />.
Here's my page with the current code.. http://demo.getcontrolfreak.com/services....
Ok.. Not sure if it's a cache thing.. but I swear this worked and now all of a sudden it's messed up again..
Am I wrong to wrap you tag in an image tag in order to right justify it?
As soon as I add <img src="<?php if (is_object($image)) {$im->output($image);}?>" align="right" /> I get broken stuff on the page.. How am I supposed to align the image to the right in order to embed it into the page?
http://demo.getcontrolfreak.com/index.php?cID=76...
Am I wrong to wrap you tag in an image tag in order to right justify it?
As soon as I add <img src="<?php if (is_object($image)) {$im->output($image);}?>" align="right" /> I get broken stuff on the page.. How am I supposed to align the image to the right in order to embed it into the page?
http://demo.getcontrolfreak.com/index.php?cID=76...
> Am I wrong to wrap you tag in an image tag in order to right justify it?
Yes.
> As soon as I add <img src="<?php if (is_object($image)) {$im->output($image);}?>" align="right" /> I get broken stuff on the page..
That's because the output() method is already creating an image tag. You're winding up with malformed mark-up.
Instead of that method, try using outputThumbnail() instead. It should put out a smaller (already scaled) version of the image.
-Steve
Yes.
> As soon as I add <img src="<?php if (is_object($image)) {$im->output($image);}?>" align="right" /> I get broken stuff on the page..
That's because the output() method is already creating an image tag. You're winding up with malformed mark-up.
Instead of that method, try using outputThumbnail() instead. It should put out a smaller (already scaled) version of the image.
-Steve
Thumbnail? That won't work.. It's not just the size I'm worried about.. I'm worried about the right justification as well.. so that the text wraps around the image. And the thumbnail image would be too small.
I would like to use this for news stories as well.. where you have the page list show the thumbnail of the news story and then when you click on it you see a larger version of the same image embedded into the story.
Here's an example..http://demo.controlfreakcms.com/demo/index.cfm/news/....
Without setting up an image attribute you have to add a news story, attach a thumbnail to the page.. Then add them page.. Then replace the content on the default page with your news story.. then insert an image.. then right justify it.. that's not even considering resizing it first.. That's WAY too many steps to simply give the user the ability to attach an image to a news story. I'm actually shocked there's no way to attach one image to a news story and have it automatically both create the thumbnail for the page list and the medium sized image for the story itself.
That is my one complaint with Concrete5 so far is that such a simple request is so complicated. I'm hoping it's just that I'm missing something.. and I'm assuming what I'm missing is how to do all this with an attribute.
I would like to use this for news stories as well.. where you have the page list show the thumbnail of the news story and then when you click on it you see a larger version of the same image embedded into the story.
Here's an example..http://demo.controlfreakcms.com/demo/index.cfm/news/....
Without setting up an image attribute you have to add a news story, attach a thumbnail to the page.. Then add them page.. Then replace the content on the default page with your news story.. then insert an image.. then right justify it.. that's not even considering resizing it first.. That's WAY too many steps to simply give the user the ability to attach an image to a news story. I'm actually shocked there's no way to attach one image to a news story and have it automatically both create the thumbnail for the page list and the medium sized image for the story itself.
That is my one complaint with Concrete5 so far is that such a simple request is so complicated. I'm hoping it's just that I'm missing something.. and I'm assuming what I'm missing is how to do all this with an attribute.
Here use it like this
<?php $ih = Loader::helper('image'); $thumb = $ih->getThumbnail($img, 40, 30); //<-- set these 2 numbers to max width and height of thumbnails echo "<img src=\"{$thumb->src}\" width=\"{$thumb->width}\" height=\"{$thumb->height}\" alt=\"\" />"; ?>
> Thumbnail? That won't work..
Actually, I think revolutiumstudio is on the right track. Think of getThumbnail() as getScaledVersionOfFullSizeImage(). It should do what you want in terms of resizing (scaling) the image to your desired dimensions. Alignment is best handled through styles. It sounds like you should consider creating a special page type for your news stories as well, so that the user has a predefined "page template" to use to streamline the process for them.
-Steve
Actually, I think revolutiumstudio is on the right track. Think of getThumbnail() as getScaledVersionOfFullSizeImage(). It should do what you want in terms of resizing (scaling) the image to your desired dimensions. Alignment is best handled through styles. It sounds like you should consider creating a special page type for your news stories as well, so that the user has a predefined "page template" to use to streamline the process for them.
-Steve
So i am using
<code> <?php $file = $c->getAttribute("staff_image");
if (is_object($file)) {
$im = Loader::helper('image');
$im->output($file);} ?>
<?php if (is_object($image)) {$im->output($image);}?></code>
How can I pull in the alt tag?
<code> <?php $file = $c->getAttribute("staff_image");
if (is_object($file)) {
$im = Loader::helper('image');
$im->output($file);} ?>
<?php if (is_object($image)) {$im->output($image);}?></code>
How can I pull in the alt tag?
perfect! thanks a lot!
That's because the output() method is already creating an image tag. You're winding up with malformed mark-up.[URL=http://www.replicabagshotsell.com]bags replica[/URL]
So i am using
<code> <?php $file = $c->getAttribute("staff_image");
if (is_object($file)) {
$im = Loader::helper('image');
$im->output($file);} ?>
<?php if (is_object($image)) {$im->output($image);}?></code>
How can I pull in the alt tag?
<code> <?php $file = $c->getAttribute("staff_image");
if (is_object($file)) {
$im = Loader::helper('image');
$im->output($file);} ?>
<?php if (is_object($image)) {$im->output($image);}?></code>
How can I pull in the alt tag?
that should do it.