图片自动获取功能
This commit is contained in:
parent
0244008b32
commit
bded9f2e98
|
@ -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
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<div class="cl"></div>
|
||||
<div style="margin-top: 10px">
|
||||
<img src="/images/org_new_style/con-left2.jpg" alt="" class="fl con-left-img"/>
|
||||
<% iamge_path = get_image_path_from_content(activity.content) %>
|
||||
<% if iamge_path.nil? %>
|
||||
<img src="/images/org_new_style/default-img.jpg" alt="" class="fl con-left-img"/>
|
||||
<% else %>
|
||||
<img src="/files/uploads/image<%= iamge_path %>" alt="" class="fl con-left-img"/>
|
||||
<% end %>
|
||||
<%=link_to activity.content.html_safe, organization_path(organization, :org_subfield_id => field.id), :class => "con-left-txt fl" %>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue