From bded9f2e988422ba29f07f2b6e9c07e601b93933 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 30 Mar 2016 18:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=87=AA=E5=8A=A8=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 10 ++++++++++ app/views/organizations/_org_new_forum.html.erb | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 19ae17015..c2ba5b03b 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -49,4 +49,14 @@ module OrganizationsHelper # Attachment.find_by_sql("SELECT * FROM `attachments` where container_id =#{field_id} and container_type = 'OrgSubfield' and is_public =1 order by created_on limit 6;") end + # 从内容中获取路径 + def get_image_path_from_content content + r = Regexp.new(/src="\/files\/uploads\/image(.+?)"/) + if r.match(content).nil? + image_path = nil + else + image_path = r.match(content)[1] + end + end + end diff --git a/app/views/organizations/_org_new_forum.html.erb b/app/views/organizations/_org_new_forum.html.erb index 627d9d3ad..8ae2036cc 100644 --- a/app/views/organizations/_org_new_forum.html.erb +++ b/app/views/organizations/_org_new_forum.html.erb @@ -1,6 +1,11 @@
- + <% iamge_path = get_image_path_from_content(activity.content) %> + <% if iamge_path.nil? %> + + <% else %> + + <% end %> <%=link_to activity.content.html_safe, organization_path(organization, :org_subfield_id => field.id), :class => "con-left-txt fl" %>