设为首页 收藏本站
查看: 1411|回复: 0

[经验分享] SharePoint 2007 文档库实现缩略图

[复制链接]

尚未签到

发表于 2015-9-24 09:07:51 | 显示全部楼层 |阅读模式
  最近太忙,到处出差,从新加坡到德国,再到美国,好容易才回到祖国的怀抱,发现自己的博客了,草长了一大推,所以决定重新好好打理这片地,等着升值.
  
  今天我们就来记录下如何在SharePoint 2007 实现文档库缩略图.
  
  需求: 创建一个SharePoint 图片库, 并需要一个conteng approve 工作流, 在approver组没有审批同意之前, 公司其他人看不到图片.
  环境:SharePoint 2007
  
  这本来是个非常简单的需求,SharePoint 2007 自带图片图,但是难在,在SharePoint 2007里,picture library 没有自带的content approve 工作流,虽然document library有,但是文档库却没有缩略图功能,真不知道microsoft怎么想的(不过SharePoint 2010都有了).
  经过短暂思考,有两张解决方案:
  1. 创建一个自定义的content approve workflow
  2. 在document library实现缩略图.
  
  综合考虑下来,觉得方案2实现更简单,更稳定.
  下面开始动手:
  经过对比document library和picture library,发现区别在于 picture library shema definition有一个"Thumbnail"列,而document library 没有.所以当你创建一个Picture Library的时候,就会创建一个"Thumbnail"列.所以我们只要在Document Library 的shema definition里加上这个列,是否就会出现"thumbnail" 列呢?
  




Note: that “Thumbnail” is a computed field and hence
it has several other field references defined inside it.
They are “ ImageWidth”,”ImageHeight”,”FSObjType”,”EncodedAbsThumbnailUrl”
and “Description”.
  
  创建缩略图列
  1. 在文档库中启用"Picture" content type, 并设置为默认content type
  2. 定义下面" thumbnail" 列
  






<Field ID="{ac7bb138-02dc-40eb-b07a-84c15575b6e9}"
ReadOnly="TRUE" Type="Computed" Name="Thumbnail"
ShowInNewForm="FALSE" ShowInFileDlg="FALSE" ShowInEditForm="FALSE"
DisplayName="Thumbnail" Sealed="TRUE" Sortable="FALSE" Filterable="FALSE"
SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Thumbnail">
            <FieldRefs>
                  <FieldRef Name="ImageWidth" />
                  <FieldRef Name="ImageHeight" />
                  <FieldRef Name="FSObjType" />
                  <FieldRef Name="EncodedAbsUrl" />
                  <FieldRef Name="Description" />
            </FieldRefs>
            <DisplayPattern>
                  <IfEqual>
                        <Expr1>
                              <LookupColumn Name="FSObjType" />
                        </Expr1>
                        <Expr2>0</Expr2>
                        <Then>
                              <IfEqual>
                                    <Expr1>
                                          <LookupColumn Name="ImageWidth" />
                                    </Expr1>
                                    <Expr2>
                                    </Expr2>
                                    <Then>
                                    </Then>
                                    <Else>
                                          <IfEqual>
                                                <Expr1>
                                                      <LookupColumn Name="ImageWidth" />
                                                </Expr1>
                                                <Expr2>0</Expr2>
                                                <Then>
                                                </Then>
                                                <Else>
                                                      <HTML><![CDATA[<a href="]]></HTML>
                                                      <URL Cmd="Display" />
                                                      <HTML><![CDATA["><img border=0 ALT="]]></HTML>
                                                      <IfEqual>
                                                            <Expr1>
                                                                  <Column Name="Description" />
                                                            </Expr1>
                                                            <Expr2>
                                                            </Expr2>
                                                            <Then>
                                                                  <HTML><![CDATA[$Resources:core,Thumbnail;]]></HTML>
                                                            </Then>
                                                            <Else>
                                                                  <Column Name="Description" HTMLEncode="TRUE" />
                                                            </Else>
                                                      </IfEqual>
                                                      <HTML><![CDATA[" SRC="]]></HTML>
                                                      <Field Name="EncodedAbsUrl" />
                                                      <HTML>
                                                            <![CDATA[">
                                        </a>
                                        ]]>
                                                      </HTML>
                                                </Else>
                                          </IfEqual>
                                    </Else>
                              </IfEqual>
                        </Then>
                  </IfEqual>
            </DisplayPattern>
   </Field>

DSC0000.gif



<Field ID="{ac7bb138-02dc-40eb-b07a-84c15575b6e9}" ReadOnly="TRUE" Type="Computed" Name="Thumbnail" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" ShowInEditForm="FALSE" DisplayName="Thumbnail" Sealed="TRUE" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Thumbnail">
            <FieldRefs>
                  <FieldRef Name="ImageWidth" />
                  <FieldRef Name="ImageHeight" />
                  <FieldRef Name="FSObjType" />
                  <FieldRef Name="EncodedAbsUrl" />
                  <FieldRef Name="Description" />
            </FieldRefs>
            <DisplayPattern>
                  <IfEqual>
                        <Expr1>
                              <LookupColumn Name="FSObjType" />
                        </Expr1>
                        <Expr2>0</Expr2>
                        <Then>
                              <IfEqual>
                                    <Expr1>
                                          <LookupColumn Name="ImageWidth" />
                                    </Expr1>
                                    <Expr2>
                                    </Expr2>
                                    <Then>
                                    </Then>
                                    <Else>
                                          <IfEqual>
                                                <Expr1>
                                                      <LookupColumn Name="ImageWidth" />
                                                </Expr1>
                                                <Expr2>0</Expr2>
                                                <Then>
                                                </Then>
                                                <Else>
                                                      <HTML><![CDATA[<a href="]]></HTML>
                                                      <URL Cmd="Display" />
                                                      <HTML><![CDATA["><img border=0 ALT="]]></HTML>
                                                      <IfEqual>
                                                            <Expr1>
                                                                  <Column Name="Description" />
                                                            </Expr1>
                                                            <Expr2>
                                                            </Expr2>
                                                            <Then>
                                                                  <HTML><![CDATA[$Resources:core,Thumbnail;]]></HTML>
                                                            </Then>
                                                            <Else>
                                                                  <Column Name="Description" HTMLEncode="TRUE" />
                                                            </Else>
                                                      </IfEqual>
                                                      <HTML><![CDATA[" SRC="]]></HTML>
                                                      <Field Name="EncodedAbsUrl" />
                                                      <HTML>
                                                            <![CDATA[">
                                        </a>
                                        ]]>
                                                      </HTML>
                                                </Else>
                                          </IfEqual>
                                    </Else>
                              </IfEqual>
                        </Then>
                  </IfEqual>
            </DisplayPattern>
   </Field>

  3. 创建一个visual studio console 程序,添加"thumbnail"列到文档库
  




using (SPSite osite = new SPSite("URL of your SharePoint Site”)
            {
                using (SPWeb oweb = osite.OpenWeb())
                {
                    SPList olist = oweb.Lists["YourListName"];
                    StreamReader rdr = new StreamReader("Definition text file path which has the field definition");
                    string fld = rdr.ReadToEnd();
                    olist.Fields.AddFieldAsXml(fld, true, SPAddFieldOptions.AddToDefaultContentType);
                    olist.Update();
                }
            }

  
  
  
  4. 现在就上传个图片试试吧
DSC0001.jpg
  
  content approve workflow
DSC0002.jpg
  .
  
  好了.结束了,好久不写,本来想写详细点,发现好累.就匆匆忙忙了.
  
  
  
  



1.      
“ImageWidth” – Gets
included when you add the picture content type


       2.       “ImageHeight”  - Gets included when
you add the picture content type


       3.       “FSObjType” – This field is available in
the BASE TYPE and will be available to all the lists  so no need to
include.


       4.       “EncodedAbsThumbnailUrl” �� This field is very specific to Picture library and will not
be included to other list just by adding the Picture content type
.


      
5.      
“Description” – Gets
included when you add the picture content type
.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-118000-1-1.html 上篇帖子: 关于SharePoint 2010体系架构的几个话题 下篇帖子: MOSS 2010:Visual Studio 2010开发体验(20)——使用ADO.NET Data Service快速访问SharePoint列表数据
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表