|
Home > Archive > Microsoft Content Management Server > July 2006 > AlignImagePlaceholderControl content
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
AlignImagePlaceholderControl content
|
|
| J Foreman 2006-07-18, 1:24 pm |
| I am trying to find the height and width of the original image stored in the
Resource Gallery the AlignImagePlaceholder is displaying. Then if the image
is bigger than a pre-defined rule (say 200px x 200px) the height and width
style of the control would be set to the rule. Otherwise the image would be
left as is if it was smaller.
I have tried code examples with no success. Your help and/or code examples
would are greatly appreciated.
Thanks in advance,
JForeman
| |
| Stefan [MSFT] 2006-07-19, 7:50 am |
| Hi J,
to get the size you would need to do a HttpWebRequest against the URL stored
in of the placeholder, consume the response stream into an Image object and
then get the size information from this object.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"J Foreman" <JForeman@discussions.microsoft.com> wrote in message
news:5DB18E55-E766-4656-9721-D185CEEC9202@microsoft.com...
>I am trying to find the height and width of the original image stored in
>the
> Resource Gallery the AlignImagePlaceholder is displaying. Then if the
> image
> is bigger than a pre-defined rule (say 200px x 200px) the height and width
> style of the control would be set to the rule. Otherwise the image would
> be
> left as is if it was smaller.
>
> I have tried code examples with no success. Your help and/or code examples
> would are greatly appreciated.
>
> Thanks in advance,
> JForeman
| |
| J Foreman 2006-07-20, 7:17 pm |
| Hi there,
I have tried dozens of examples. Could you help with an example of
something that would work? This is as far as I can get without errors:
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://localhost"+sUrl);
I was grabbing the .Src property of the image placeholder object and then
prefixing it with "http://servername" (when I type this into the browser I
can see the image).
I want to get the original resource gallery image height and width. I am
executing this in the Render() method of the AlignImagePlaceholderControl
object.
Thanks,
JForeman
"Stefan [MSFT]" wrote:
> Hi J,
>
> to get the size you would need to do a HttpWebRequest against the URL stored
> in of the placeholder, consume the response stream into an Image object and
> then get the size information from this object.
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> Check out the new book as well: Advanced MCMS development:
> http://tinyurl.com/8ugwj
> ----------------------
>
>
> "J Foreman" <JForeman@discussions.microsoft.com> wrote in message
> news:5DB18E55-E766-4656-9721-D185CEEC9202@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2006-07-21, 7:21 am |
| Hi J,
the code looks good.
What kind of error do you get?
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"J Foreman" <JForeman@discussions.microsoft.com> wrote in message
news:A1A3B380-014B-4D0B-8913-CC57EED6D423@microsoft.com...[vbcol=seagreen]
> Hi there,
>
> I have tried dozens of examples. Could you help with an example of
> something that would work? This is as far as I can get without errors:
>
> HttpWebRequest myHttpWebRequest =
> (HttpWebRequest)WebRequest.Create("http://localhost"+sUrl);
>
> I was grabbing the .Src property of the image placeholder object and then
> prefixing it with "http://servername" (when I type this into the browser I
> can see the image).
>
> I want to get the original resource gallery image height and width. I am
> executing this in the Render() method of the AlignImagePlaceholderControl
> object.
>
> Thanks,
> JForeman
>
> "Stefan [MSFT]" wrote:
>
| |
| J Foreman 2006-07-21, 1:17 pm |
| Hi there,
I receive the following error:
"The remote server returned an error: (401) Unauthorized."
I am using a valid subcriber userid and password, but perhaps the domain is
incorrect? perhaps I should be impersonnating the mcmssytem account?
Here is my code:
ImagePlaceholder impPh =
(ImagePlaceholder)CmsHttpContext.Current.Posting.Placeholders[id];
string sUrl = impPh.Src;
string newhtml;
if (sUrl != "")
{
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://localhost"+sUrl);
NetworkCredential nwkCredential = new
NetworkCredential("validSubscriberUserID","validSubscriberPW","WinNT://validDomainController");
myRequest.Credentials = nwkCredential;
Stream sStream = null;
HttpWebResponse myResponse = (HttpWebResponse)(myRequest).GetResponse();
sStream = myResponse.GetResponseStream();
System.Drawing.Image imgPicture = System.Drawing.Image.FromStream(sStream);
double dHeight = imgPicture.Height;
double dWidth = imgPicture.Width;
if (dHeight > 280)
{
dHeight = 280;
}
if (dWidth > 200)
{
dWidth = 200;
}
newhtml = orightml.Replace("<img ","<img
align="+imageAlignment.ToString()+" style=\"height:" + dHeight + "px;width:"
+ dWidth + "px;");
}
else
{
newhtml = orightml.Replace("<img ","<img
align="+imageAlignment.ToString()+ " ");
}
output.Write(newhtml);
Thank you so much for your help.
JForeman
"Stefan [MSFT]" wrote:
> Hi J,
>
> the code looks good.
> What kind of error do you get?
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> Check out the new book as well: Advanced MCMS development:
> http://tinyurl.com/8ugwj
> ----------------------
>
>
> "J Foreman" <JForeman@discussions.microsoft.com> wrote in message
> news:A1A3B380-014B-4D0B-8913-CC57EED6D423@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2006-07-21, 1:17 pm |
| Hi J,
ok your server requires authentication.
You need to send credentials with your web request.
Please provide in the following format:
NetworkCredential nwkCredential = new
NetworkCredential("validSubscriberUserID","validSubscriberPW","validDomainController");
So don't add the WinNT:// stuff.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
Check out the new book as well: Advanced MCMS development:
http://tinyurl.com/8ugwj
----------------------
"J Foreman" <JForeman@discussions.microsoft.com> wrote in message
news:227998FA-C3A3-4288-8336-7CE77C0EF783@microsoft.com...[vbcol=seagreen]
> Hi there,
>
> I receive the following error:
>
> "The remote server returned an error: (401) Unauthorized."
>
> I am using a valid subcriber userid and password, but perhaps the domain
> is
> incorrect? perhaps I should be impersonnating the mcmssytem account?
>
> Here is my code:
>
> ImagePlaceholder impPh =
> (ImagePlaceholder)CmsHttpContext.Current.Posting.Placeholders[id];
> string sUrl = impPh.Src;
> string newhtml;
>
> if (sUrl != "")
> {
> HttpWebRequest myRequest =
> (HttpWebRequest)WebRequest.Create("http://localhost"+sUrl);
> NetworkCredential nwkCredential = new
> NetworkCredential("validSubscriberUserID","validSubscriberPW","WinNT://validDomainController");
> myRequest.Credentials = nwkCredential;
>
> Stream sStream = null;
> HttpWebResponse myResponse = (HttpWebResponse)(myRequest).GetResponse();
> sStream = myResponse.GetResponseStream();
> System.Drawing.Image imgPicture =
> System.Drawing.Image.FromStream(sStream);
> double dHeight = imgPicture.Height;
> double dWidth = imgPicture.Width;
>
> if (dHeight > 280)
> {
> dHeight = 280;
> }
> if (dWidth > 200)
> {
> dWidth = 200;
> }
> newhtml = orightml.Replace("<img ","<img
> align="+imageAlignment.ToString()+" style=\"height:" + dHeight +
> "px;width:"
> + dWidth + "px;");
> }
> else
> {
> newhtml = orightml.Replace("<img ","<img
> align="+imageAlignment.ToString()+ " ");
> }
> output.Write(newhtml);
>
> Thank you so much for your help.
> JForeman
>
> "Stefan [MSFT]" wrote:
>
| |
| J Foreman 2006-07-25, 1:18 pm |
| Once again, thanks Stefan. Simply having the domain name worked.
JForeman
"Stefan [MSFT]" wrote:
> Hi J,
>
> ok your server requires authentication.
> You need to send credentials with your web request.
> Please provide in the following format:
>
> NetworkCredential nwkCredential = new
> NetworkCredential("validSubscriberUserID","validSubscriberPW","validDomainController");
>
> So don't add the WinNT:// stuff.
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> Check out the new book as well: Advanced MCMS development:
> http://tinyurl.com/8ugwj
> ----------------------
>
>
> "J Foreman" <JForeman@discussions.microsoft.com> wrote in message
> news:227998FA-C3A3-4288-8336-7CE77C0EF783@microsoft.com...
>
>
>
|
|
|
|
|